diff --git a/NotesTableView.h b/NotesTableView.h index a44e70dc..92664232 100755 --- a/NotesTableView.h +++ b/NotesTableView.h @@ -88,6 +88,7 @@ typedef struct _ViewLocationContext { - (NoteAttributeColumn*)noteAttributeColumnForIdentifier:(NSString*)identifier; - (void)incrementNoteSelection:(id)sender; +- (void)incrementNoteSelectionWithDummyItem:(unichar) keyChar; - (id)labelsListSource; - (void)setLabelsListSource:(id)labelsSource; diff --git a/NotesTableView.m b/NotesTableView.m index 89450a01..79b7c2f4 100755 --- a/NotesTableView.m +++ b/NotesTableView.m @@ -22,6 +22,7 @@ #import "UnifiedCell.h" #import "HeaderViewWithMenu.h" #import "NSString_NV.h" +#import "LinkingEditor.h" #define STATUS_STRING_FONT_SIZE 16.0f #define SET_DUAL_HIGHLIGHTS 0 @@ -862,6 +863,7 @@ - (void)keyDown:(NSEvent*)theEvent { } + enum { kNext_Tag = 'j', kPrev_Tag = 'k' }; //use this method to catch next note/prev note before View menu does @@ -886,29 +888,32 @@ - (BOOL)performKeyEquivalent:(NSEvent *)theEvent { keyChar = [theEvent firstCharacterIgnoringModifiers]; /* first gets '\n' when control key is set, so fall back to ignoringModifiers */ } - // Handle J and K + // Handle J and K for both Control and Command if ( keyChar == kNext_Tag || keyChar == kPrev_Tag ) { if (mods & NSAlternateKeyMask) { [self selectRowAndScroll:((keyChar == kNext_Tag) ? [self numberOfRows] - 1 : 0)]; } else { - if (!dummyItem) dummyItem = [[NSMenuItem alloc] init]; - [dummyItem setTag:keyChar]; - [self incrementNoteSelection:dummyItem]; + [self incrementNoteSelectionWithDummyItem: keyChar]; } return YES; } - // Handle N and P, but only when control is pressed + // Handle N and P, but only when Control is pressed if ( (keyChar == 'n' || keyChar == 'p') && (!isCommandKeyPressed)) { // Determine if the note editing pane is selected: - BOOL isEditorFirstResponder = [@"LinkingEditor" isEqualToString: NSStringFromClass([[[NSApp mainWindow] firstResponder] class])]; /* Can't use +isKindOfClass because LinkingEditor is a forwarding class and may not respond to +class */ + BOOL isEditorFirstResponder = [[[NSApp mainWindow] firstResponder] isKindOfClass: [LinkingEditor class]]; if (!isEditorFirstResponder) { - if (!dummyItem) dummyItem = [[NSMenuItem alloc] init]; - [dummyItem setTag:((keyChar == 'n') ? kNext_Tag : kPrev_Tag)]; - [self incrementNoteSelection:dummyItem]; + [self incrementNoteSelectionWithDummyItem: (keyChar == 'n') ? kNext_Tag : kPrev_Tag]; return YES; } } + + // Make Control-[ equivalent to Escape + if ( (keyChar == '[' ) && (!isCommandKeyPressed)) { + AppController* appDelegate = (AppController*)[NSApp delegate]; + [appDelegate bringFocusToControlField:nil]; + return YES; + } } return [super performKeyEquivalent:theEvent]; @@ -932,6 +937,12 @@ - (void)incrementNoteSelection:(id)sender { [self selectRowAndScroll:rowNumber]; } +- (void)incrementNoteSelectionWithDummyItem:(unichar) keyChar { + if (!dummyItem) dummyItem = [[NSMenuItem alloc] init]; + [dummyItem setTag:keyChar]; + [self incrementNoteSelection:dummyItem]; +} + - (void)deselectAll:(id)sender { [super deselectAll:sender];