Skip to content

Commit

Permalink
Added modifierFlags parameter to mouseUp/Down delegate methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludovico Giammarino committed May 30, 2016
1 parent 38ec08a commit 41087ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions JNWCollectionView/JNWCollectionViewFramework.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ typedef NS_ENUM(NSInteger, JNWCollectionViewScrollPosition) {
@protocol JNWCollectionViewDelegate <NSObject>

@optional
/// Tells the delegate that the mouse is down inside of the item at the specified index path.
- (void)collectionView:(JNWCollectionView *)collectionView mouseDownInItemAtIndexPath:(NSIndexPath *)indexPath;
/// Tells the delegate that the mouse is down inside of the item at the specified index path with specific modifier flags.
- (void)collectionView:(JNWCollectionView *)collectionView mouseDownInItemAtIndexPath:(NSIndexPath *)indexPath withModifierFlags:(NSEventModifierFlags)modFlags;

/// Tells the delegate that the mouse click originating from the item at the specified index path is now up.
/// Tells the delegate that the mouse click originating from the item at the specified index path is now up with specific modifier flags.
///
/// The mouse up event can occur outside of the originating cell.
- (void)collectionView:(JNWCollectionView *)collectionView mouseUpInItemAtIndexPath:(NSIndexPath *)indexPath;
- (void)collectionView:(JNWCollectionView *)collectionView mouseUpInItemAtIndexPath:(NSIndexPath *)indexPath withModifierFlags:(NSEventModifierFlags)modFlags;

/// Asks the delegate if the item at the specified index path should be selected.
- (BOOL)collectionView:(JNWCollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath;
Expand Down
8 changes: 4 additions & 4 deletions JNWCollectionView/JNWCollectionViewFramework.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ - (id)initWithCoder:(NSCoder *)aDecoder {

- (void)setDelegate:(id<JNWCollectionViewDelegate>)delegate {
_delegate = delegate;
_collectionViewFlags.delegateMouseUp = [delegate respondsToSelector:@selector(collectionView:mouseUpInItemAtIndexPath:)];
_collectionViewFlags.delegateMouseDown = [delegate respondsToSelector:@selector(collectionView:mouseDownInItemAtIndexPath:)];
_collectionViewFlags.delegateMouseUp = [delegate respondsToSelector:@selector(collectionView:mouseUpInItemAtIndexPath: withModifierFlags:)];
_collectionViewFlags.delegateMouseDown = [delegate respondsToSelector:@selector(collectionView:mouseDownInItemAtIndexPath:withModifierFlags:)];
_collectionViewFlags.delegateShouldSelect = [delegate respondsToSelector:@selector(collectionView:shouldSelectItemAtIndexPath:)];
_collectionViewFlags.delegateDidSelect = [delegate respondsToSelector:@selector(collectionView:didSelectItemAtIndexPath:)];
_collectionViewFlags.delegateShouldDeselect = [delegate respondsToSelector:@selector(collectionView:shouldDeselectItemAtIndexPath:)];
Expand Down Expand Up @@ -1015,7 +1015,7 @@ - (void)mouseDownInCollectionViewCell:(JNWCollectionViewCell *)cell withEvent:(N
}

if (_collectionViewFlags.delegateMouseDown) {
[self.delegate collectionView:self mouseDownInItemAtIndexPath:indexPath];
[self.delegate collectionView:self mouseDownInItemAtIndexPath:indexPath withModifierFlags:event.modifierFlags];
}

// Detect if modifier flags are held down.
Expand All @@ -1032,7 +1032,7 @@ - (void)mouseDownInCollectionViewCell:(JNWCollectionViewCell *)cell withEvent:(N
- (void)mouseUpInCollectionViewCell:(JNWCollectionViewCell *)cell withEvent:(NSEvent *)event {
if (_collectionViewFlags.delegateMouseUp) {
NSIndexPath *indexPath = [self indexPathForCell:cell];
[self.delegate collectionView:self mouseUpInItemAtIndexPath:indexPath];
[self.delegate collectionView:self mouseUpInItemAtIndexPath:indexPath withModifierFlags:event.modifierFlags];
}
}

Expand Down

0 comments on commit 41087ce

Please sign in to comment.