Skip to content
This repository has been archived by the owner on Nov 1, 2017. It is now read-only.

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
joshaber committed Aug 10, 2011
2 parents 1987cab + 044e5ca commit 45e1552
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 11 deletions.
10 changes: 9 additions & 1 deletion ExampleProject/ConcordeExample/ExampleView.m
Expand Up @@ -162,8 +162,16 @@ - (void)tableView:(TUITableView *)tableView didClickRowAtIndexPath:(TUIFastIndex
}

if(event.type == NSRightMouseUp){
NSLog(@"right mouse up");
// show context menu
}
}
- (BOOL)tableView:(TUITableView *)tableView shouldSelectRowAtIndexPath:(TUIFastIndexPath *)indexPath forEvent:(NSEvent *)event{
switch (event.type) {
case NSRightMouseDown:
return NO;
}

return YES;
}

@end
6 changes: 4 additions & 2 deletions lib/UIKit/TUITableView.h
Expand Up @@ -41,9 +41,11 @@ typedef enum {
@optional

- (void)tableView:(TUITableView *)tableView willDisplayCell:(TUITableViewCell *)cell forRowAtIndexPath:(TUIFastIndexPath *)indexPath; // not implemented yet
- (void)tableView:(TUITableView *)tableView didSelectRowAtIndexPath:(TUIFastIndexPath *)indexPath; // happens on mouse down
- (void)tableView:(TUITableView *)tableView didSelectRowAtIndexPath:(TUIFastIndexPath *)indexPath; // happens on left/right mouse down, key up/down
- (void)tableView:(TUITableView *)tableView didDeselectRowAtIndexPath:(TUIFastIndexPath *)indexPath;
- (void)tableView:(TUITableView *)tableView didClickRowAtIndexPath:(TUIFastIndexPath *)indexPath withEvent:(NSEvent *)event; // happens on mouse up (can look at clickCount)
- (void)tableView:(TUITableView *)tableView didClickRowAtIndexPath:(TUIFastIndexPath *)indexPath withEvent:(NSEvent *)event; // happens on left/right mouse up (can look at clickCount)

- (BOOL)tableView:(TUITableView*)tableView shouldSelectRowAtIndexPath:(TUIFastIndexPath*)indexPath forEvent:(NSEvent*)event; // YES, if not implemented

@end

Expand Down
11 changes: 7 additions & 4 deletions lib/UIKit/TUITableView.m
Expand Up @@ -873,9 +873,10 @@ - (BOOL)performKeyAction:(NSEvent *)event
}
newIndexPath = [TUIFastIndexPath indexPathForRow:row inSection:section];
}

[self selectRowAtIndexPath:newIndexPath animated:self.animateSelectionChanges scrollPosition:TUITableViewScrollPositionToVisible];

if(![_delegate respondsToSelector:@selector(tableView:shouldSelectRowAtIndexPath:forEvent:)] || [_delegate tableView:self shouldSelectRowAtIndexPath:newIndexPath forEvent:event]){
[self selectRowAtIndexPath:newIndexPath animated:self.animateSelectionChanges scrollPosition:TUITableViewScrollPositionToVisible];
}

return YES;
}

Expand Down Expand Up @@ -903,7 +904,9 @@ - (BOOL)performKeyAction:(NSEvent *)event
newIndexPath = [TUIFastIndexPath indexPathForRow:row inSection:section];
}

[self selectRowAtIndexPath:newIndexPath animated:self.animateSelectionChanges scrollPosition:TUITableViewScrollPositionToVisible];
if(![_delegate respondsToSelector:@selector(tableView:shouldSelectRowAtIndexPath:forEvent:)] || [_delegate tableView:self shouldSelectRowAtIndexPath:newIndexPath forEvent:event]){
[self selectRowAtIndexPath:newIndexPath animated:self.animateSelectionChanges scrollPosition:TUITableViewScrollPositionToVisible];
}

return YES;
}
Expand Down
25 changes: 21 additions & 4 deletions lib/UIKit/TUITableViewCell.m
Expand Up @@ -74,11 +74,14 @@ - (BOOL)acceptsFirstMouse:(NSEvent *)event

- (void)mouseDown:(NSEvent *)event
{
[super mouseDown:event];

TUITableView *tableView = self.tableView;
[tableView selectRowAtIndexPath:self.indexPath animated:tableView.animateSelectionChanges scrollPosition:TUITableViewScrollPositionNone];
[super mouseDown:event]; // may make the text renderer first responder, so we want to do the selection before this
_tableViewCellFlags.highlighted = 1;
[self setNeedsDisplay];
if(![tableView.delegate respondsToSelector:@selector(tableView:shouldSelectRowAtIndexPath:forEvent:)] || [tableView.delegate tableView:tableView shouldSelectRowAtIndexPath:self.indexPath forEvent:event]){
[tableView selectRowAtIndexPath:self.indexPath animated:tableView.animateSelectionChanges scrollPosition:TUITableViewScrollPositionNone];
_tableViewCellFlags.highlighted = 1;
[self setNeedsDisplay];
}
}

- (void)mouseUp:(NSEvent *)event
Expand All @@ -95,8 +98,22 @@ - (void)mouseUp:(NSEvent *)event
}
}

- (void)rightMouseDown:(NSEvent *)event{
[super rightMouseDown:event];

TUITableView *tableView = self.tableView;
if(![tableView.delegate respondsToSelector:@selector(tableView:shouldSelectRowAtIndexPath:forEvent:)] || [tableView.delegate tableView:tableView shouldSelectRowAtIndexPath:self.indexPath forEvent:event]){
[tableView selectRowAtIndexPath:self.indexPath animated:tableView.animateSelectionChanges scrollPosition:TUITableViewScrollPositionNone];
_tableViewCellFlags.highlighted = 1;
[self setNeedsDisplay];
}
}

- (void)rightMouseUp:(NSEvent *)event{
[super rightMouseUp:event];
_tableViewCellFlags.highlighted = 0;
[self setNeedsDisplay];

if([self eventInside:event]) {
TUITableView *tableView = self.tableView;
if([tableView.delegate respondsToSelector:@selector(tableView:didClickRowAtIndexPath:withEvent:)]){
Expand Down

0 comments on commit 45e1552

Please sign in to comment.