Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
Merge of fix for issue #9 from @k7d into main project
Browse files Browse the repository at this point in the history
  • Loading branch information
brutella committed Oct 20, 2011
1 parent 65addb3 commit ad5d0af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 8 additions & 4 deletions lib/UIKit/TUITableView.m
Expand Up @@ -1082,8 +1082,8 @@ - (void)_makeRowAtIndexPathFirstResponder:(TUIFastIndexPath *)indexPath

- (void)selectRowAtIndexPath:(TUIFastIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(TUITableViewScrollPosition)scrollPosition
{

if([indexPath isEqual:[self indexPathForSelectedRow]]) {
TUIFastIndexPath *oldIndexPath = [self indexPathForSelectedRow];
if([indexPath isEqual:oldIndexPath]) {
// just scroll to visible
} else {
[self deselectRowAtIndexPath:[self indexPathForSelectedRow] animated:animated];
Expand All @@ -1100,8 +1100,12 @@ - (void)selectRowAtIndexPath:(TUIFastIndexPath *)indexPath animated:(BOOL)animat
}

}

[self _makeRowAtIndexPathFirstResponder:indexPath];

NSResponder *firstResponder = [self.nsWindow firstResponder];
if(firstResponder == self || firstResponder == [self cellForRowAtIndexPath:oldIndexPath]) {
// only make cell first responder if the table view already is first responder
[self _makeRowAtIndexPathFirstResponder:indexPath];
}
[self scrollToRowAtIndexPath:indexPath atScrollPosition:scrollPosition animated:animated];
}

Expand Down
4 changes: 3 additions & 1 deletion lib/UIKit/TUITableViewCell.m
Expand Up @@ -88,7 +88,9 @@ - (void)mouseDown:(NSEvent *)event
[self.tableView __mouseDownInCell:self offset:_mouseOffset event:event];

TUITableView *tableView = self.tableView;
[tableView selectRowAtIndexPath:self.indexPath animated:tableView.animateSelectionChanges scrollPosition:TUITableViewScrollPositionNone];
[self.nsWindow makeFirstResponder:tableView];
[tableView selectRowAtIndexPath:self.indexPath animated:YES scrollPosition:TUITableViewScrollPositionNone];

[super mouseDown:event]; // may make the text renderer first responder, so we want to do the selection before this

if(![tableView.delegate respondsToSelector:@selector(tableView:shouldSelectRowAtIndexPath:forEvent:)] || [tableView.delegate tableView:tableView shouldSelectRowAtIndexPath:self.indexPath forEvent:event]){
Expand Down

0 comments on commit ad5d0af

Please sign in to comment.