IKImageBrowserView selection problems

579 views Asked by At

For example, the initial status is all images selected enter image description here

when I clicked one, I hope it unselected, but the current status is no response for the action enter image description here

Is there some settings? Thanks for any help.

1

There are 1 answers

0
droughtrain On BEST ANSWER

At last, I found the solution. add the following code in the same file of your 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