2013-01-21 50 views

回答

1

最後,我找到了解決方案。將下面的代碼添加到IKImageBrowserView的同一個文件中。

@interface IKImageBrowserView (event) 

- (void)mouseDown:(NSEvent *)theEvent ; 

@end 

@implementation IKImageBrowserView (event) 

- (void)mouseDown:(NSEvent *)theEvent 
{ 
    NSPoint pt = [self convertPoint: theEvent.locationInWindow fromView: nil]; 

    NSInteger index = [self indexOfItemAtPoint:pt] ; 

    if (index != NSNotFound) 
    { 
    NSUInteger ge ; 
    NSUInteger le ; 
    NSIndexSet* set = [self selectionIndexes] ; 
    NSMutableIndexSet* mutableSet = [[NSMutableIndexSet alloc] init] ; 

    [mutableSet addIndexes:set] ; 

    ge = [mutableSet indexGreaterThanOrEqualToIndex:index] ; 
    le = [mutableSet indexLessThanOrEqualToIndex:index] ; 

    if ((ge == le) && (ge != NSNotFound)) 
    { 
     [mutableSet removeIndex:index] ; 
    } 
    else 
    { 
     [mutableSet addIndex:index] ; 
    } 

    [self setSelectionIndexes:mutableSet byExtendingSelection:NO] ; 
//  [ mutableSet release ]; 
    } 
} 

@end