Skip to content

Loading…

Added support for right mouse clicks in view #35

Merged
merged 2 commits into from

2 participants

@brutella

Also routing right mouse events to table view delegate

@brutella brutella Added support for right mouse clicks in view
Routing right mouse events to table view delegate
9e1f038
@atebits

Should be "right mouse up"

@atebits atebits merged commit 6af2d4e into twitter:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 4, 2011
  1. @brutella

    Added support for right mouse clicks in view

    brutella committed
    Routing right mouse events to table view delegate
Commits on Aug 5, 2011
  1. @brutella
View
4 ExampleProject/ConcordeExample/ExampleView.m
@@ -160,6 +160,10 @@ - (void)tableView:(TUITableView *)tableView didClickRowAtIndexPath:(TUIFastIndex
if([event clickCount] == 1) {
// do something cool
}
+
+ if(event.type == NSRightMouseUp){
+ NSLog(@"right mouse up");
+ }
}
@end
View
18 lib/UIKit/TUINSView.m
@@ -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];
View
10 lib/UIKit/TUITableViewCell.m
@@ -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;
View
2 lib/UIKit/TUIView+Event.h
@@ -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;
View
21 lib/UIKit/TUIView+Event.m
@@ -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];
@@ -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
{
Something went wrong with that request. Please try again.