diff options
author | Max Lohrmann <dmoagx@users.noreply.github.com> | 2016-04-16 21:29:36 +0200 |
---|---|---|
committer | Max Lohrmann <dmoagx@users.noreply.github.com> | 2016-04-16 21:29:36 +0200 |
commit | d8ee2f96227b1e35163fa19a62cbd17279aadc17 (patch) | |
tree | 73f2b7c2c136b0ed161afef8646b35763d80cb59 /Source | |
parent | f9f3764f9eee380a3c39e0db5cb669f3617339ef (diff) | |
download | sequelpro-d8ee2f96227b1e35163fa19a62cbd17279aadc17.tar.gz sequelpro-d8ee2f96227b1e35163fa19a62cbd17279aadc17.tar.bz2 sequelpro-d8ee2f96227b1e35163fa19a62cbd17279aadc17.zip |
* Add the possibility to navigate table list by arrow keys when using table filter (#2468)
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPTablesList.m | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index 67f26c31..338ecd7e 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -1624,23 +1624,42 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; */ - (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command { - - // When enter/return is used, save the row. - if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(insertNewline:)] ) { - [[control window] makeFirstResponder:control]; - return YES; - - // When the escape key is used, abort the rename. - } else if ( [[control window] methodForSelector:command] == [[control window] methodForSelector:@selector(cancelOperation:)] || - [textView methodForSelector:command] == [textView methodForSelector:@selector(complete:)] ) { - - [control abortEditing]; - [[tablesListView window] makeFirstResponder:tablesListView]; - - return YES; - } else{ - return NO; + + if(control == listFilterField) { + NSInteger newRow = NSNotFound; + // Arrow down/up will usually go to start/end of the text field. we want to change the selected table row. + if (command == @selector(moveDown:)) { + newRow = [tablesListView selectedRow] + 1; + } + + if (command == @selector(moveUp:)) { + newRow = [tablesListView selectedRow] - 1; + } + + if(newRow != NSNotFound) { + //we can't go below 1 or we'll select the table header + [tablesListView selectRowIndexes:[NSIndexSet indexSetWithIndex:(newRow > 0 ? newRow : 1)] byExtendingSelection:NO]; + return YES; + } + } + else { + // When enter/return is used, save the row. + if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(insertNewline:)] ) { + [[control window] makeFirstResponder:control]; + return YES; + } + // When the escape key is used, abort the rename. + else if ( [[control window] methodForSelector:command] == [[control window] methodForSelector:@selector(cancelOperation:)] || + [textView methodForSelector:command] == [textView methodForSelector:@selector(complete:)] ) { + + [control abortEditing]; + [[tablesListView window] makeFirstResponder:tablesListView]; + + return YES; + } } + + return NO; } #endif |