Skip to content

Commit

Permalink
Added support for right mouse clicks in view
Browse files Browse the repository at this point in the history
Routing right mouse events to table view delegate
  • Loading branch information
brutella committed Aug 4, 2011
1 parent 7f82056 commit 9e1f038
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ExampleProject/ConcordeExample/ExampleView.m
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ - (void)tableView:(TUITableView *)tableView didClickRowAtIndexPath:(TUIFastIndex
if([event clickCount] == 1) {
// do something cool
}

if(event.type == NSRightMouseUp){
NSLog(@"left mouse up");
}
}

@end
18 changes: 18 additions & 0 deletions lib/UIKit/TUINSView.m
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,24 @@ - (void)mouseMoved:(NSEvent *)event
[self _updateHoverViewWithEvent:event];
}

- (void)rightMouseDown:(NSEvent *)event
{
[_trackingView release];
_trackingView = [[self viewForEvent:event] retain];
[_trackingView rightMouseDown:event];
[TUITooltipWindow endTooltip];
}

- (void)rightMouseUp:(NSEvent *)event
{
TUIView *lastTrackingView = [[_trackingView retain] autorelease];

[_trackingView release];
_trackingView = nil;

[lastTrackingView rightMouseUp:event]; // after _trackingView set to nil, will call mouseUp:fromSubview:
}

- (void)scrollWheel:(NSEvent *)event
{
[[self viewForEvent:event] scrollWheel:event];
Expand Down
10 changes: 10 additions & 0 deletions lib/UIKit/TUITableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ - (void)mouseUp:(NSEvent *)event
}
}

- (void)rightMouseUp:(NSEvent *)event{
[super rightMouseUp:event];
if([self eventInside:event]) {
TUITableView *tableView = self.tableView;
if([tableView.delegate respondsToSelector:@selector(tableView:didClickRowAtIndexPath:withEvent:)]){
[tableView.delegate tableView:tableView didClickRowAtIndexPath:self.indexPath withEvent:event];
}
}
}

- (BOOL)isHighlighted
{
return _tableViewCellFlags.highlighted;
Expand Down
2 changes: 2 additions & 0 deletions lib/UIKit/TUIView+Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
- (void)mouseDown:(NSEvent *)event onSubview:(TUIView *)subview;
- (void)mouseDragged:(NSEvent *)event onSubview:(TUIView *)subview;
- (void)mouseUp:(NSEvent *)event fromSubview:(TUIView *)subview;
- (void)rightMouseDown:(NSEvent *)event onSubview:(TUIView *)subview;
- (void)rightMouseUp:(NSEvent *)event fromSubview:(TUIView *)subview;
- (void)mouseEntered:(NSEvent *)event onSubview:(TUIView *)subview;
- (void)mouseExited:(NSEvent *)event fromSubview:(TUIView *)subview;

Expand Down
21 changes: 21 additions & 0 deletions lib/UIKit/TUIView+Event.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ - (void)mouseUp:(NSEvent *)event
[self.superview mouseUp:event fromSubview:self];
}

- (void)rightMouseDown:(NSEvent *)event
{
[self.superview rightMouseDown:event onSubview:self];
}

- (void)rightMouseUp:(NSEvent *)event
{
[self.superview rightMouseUp:event fromSubview:self];
}

- (void)mouseDragged:(NSEvent *)event
{
[_currentTextRenderer mouseDragged:event];
Expand Down Expand Up @@ -190,6 +200,17 @@ - (void)mouseUp:(NSEvent *)event fromSubview:(TUIView *)subview
// [self.superview mouseUp:event fromSubview:self];
}

- (void)rightMouseDown:(NSEvent *)event onSubview:(TUIView *)subview
{

}

- (void)rightMouseUp:(NSEvent *)event fromSubview:(TUIView *)subview
{
// same question here as for mouseUp:fromSubview:
[self.superview rightMouseUp:event fromSubview:subview];
}

- (void)mouseEntered:(NSEvent *)event onSubview:(TUIView *)subview
{

Expand Down

0 comments on commit 9e1f038

Please sign in to comment.