Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #74 from brutella/k7d_integration

Merge of fix for issue #9 from @k7d into main project
  • Loading branch information...
commit a555cd84e746df5afb3358f23a1b791c24c186bd 2 parents c123c1f + ad5d0af
@atebits atebits authored
Showing with 11 additions and 5 deletions.
  1. +8 −4 lib/UIKit/TUITableView.m
  2. +3 −1 lib/UIKit/TUITableViewCell.m
View
12 lib/UIKit/TUITableView.m
@@ -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];
@@ -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];
}
View
4 lib/UIKit/TUITableViewCell.m
@@ -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]){
Please sign in to comment.
Something went wrong with that request. Please try again.