Permalink
Browse files

Shift-selection now also selects the items in between

  • Loading branch information...
pieteromvlee committed Jul 31, 2011
1 parent 855285d commit e916b592f8a99907ca64caccd35b3cf5d0d4d757
Showing with 12 additions and 2 deletions.
  1. +12 −2 BCCollectionView+Mouse.m
View
@@ -35,8 +35,18 @@ - (void)mouseDown:(NSEvent *)theEvent
if ([self shiftOrCommandKeyPressed] && [self.originalSelectionIndexes containsIndex:index])
[self deselectItemAtIndex:index];
- else
- [self selectItemAtIndex:index];
+ else {
+ if ([NSEvent modifierFlags] & NSCommandKeyMask || [[self originalSelectionIndexes] count] == 0)
+ [self selectItemAtIndex:index];
+ else if ([NSEvent modifierFlags] & NSShiftKeyMask) {
+ NSInteger one = [[self originalSelectionIndexes] lastIndex];
+ NSInteger two = index;
+ if (two > one)
+ [self selectItemsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(MIN(one,two), 1+MAX(one,two)-MIN(one,two))]];
+ else
+ [self selectItemsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(MIN(one,two), MAX(one,two)-MIN(one,two))]];
+ }
+ }
}
- (void)regularMouseDragged:(NSEvent *)anEvent

0 comments on commit e916b59

Please sign in to comment.