Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Go to database: change the way the arrow keys are forwarded, so the l…
…ist will scroll (#2343)
  • Loading branch information
dmoagx committed Dec 6, 2015
1 parent 798786a commit 7364a3b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions Source/SPGotoDatabaseController.m
Expand Up @@ -396,15 +396,30 @@ - (BOOL)control:(NSControl *)control textView:(NSTextView *)fieldEditor doComman
[cancelButton performClick:control];
return YES;
}

// the keyboard event is the preferable choice as it will also scroll the window
// TODO: check if the other path is ever used
NSEvent *currentEvent = [NSApp currentEvent];
BOOL isKeyDownEvent = ([currentEvent type] == NSKeyDown);

// Arrow down/up will usually go to start/end of the text field. we want to change the selected table row.
if (commandSelector == @selector(moveDown:)) {
[databaseListView selectRowIndexes:[NSIndexSet indexSetWithIndex:([databaseListView selectedRow]+1)] byExtendingSelection:NO];
if(isKeyDownEvent) {
[databaseListView keyDown:currentEvent];
}
else {
[databaseListView selectRowIndexes:[NSIndexSet indexSetWithIndex:([databaseListView selectedRow]+1)] byExtendingSelection:NO];
}
return YES;
}

if (commandSelector == @selector(moveUp:)) {
[databaseListView selectRowIndexes:[NSIndexSet indexSetWithIndex:([databaseListView selectedRow]-1)] byExtendingSelection:NO];
if(isKeyDownEvent) {
[databaseListView keyDown:currentEvent];
}
else {
[databaseListView selectRowIndexes:[NSIndexSet indexSetWithIndex:([databaseListView selectedRow]-1)] byExtendingSelection:NO];
}
return YES;
}

Expand Down

0 comments on commit 7364a3b

Please sign in to comment.