Skip to content

Commit

Permalink
Add Control-J/-K shortcut for prev/next note
Browse files Browse the repository at this point in the history
This matches the key bindings from other apps that use similar shortcuts
for previous next (notably LaunchBar). This is handled in the
performKeyEquivalent method so that the menu item will not change, and
the original Command-J/-K continue to work as normal.
  • Loading branch information
csexton authored and scrod committed Jan 30, 2011
1 parent 02d7f65 commit ef05b9a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions NotesTableView.m
Expand Up @@ -869,9 +869,17 @@ - (void)keyDown:(NSEvent*)theEvent {
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent {

unsigned mods = [theEvent modifierFlags];
if ((mods & NSCommandKeyMask) && ((mods & NSShiftKeyMask) == 0)) {

// Also catch Ctrl-J/-K to match the shortcuts of other apps
if (((mods & NSCommandKeyMask) || (mods & NSControlKeyMask)) && ((mods & NSShiftKeyMask) == 0)) {

unichar keyChar = [theEvent firstCharacter]; /*cannot use ignoringModifiers here as it subverts the Dvorak-Qwerty-CMD keyboard layout */
unichar keyChar = ' ';
if (mods & NSCommandKeyMask) {
keyChar = [theEvent firstCharacter]; /*cannot use ignoringModifiers here as it subverts the Dvorak-Qwerty-CMD keyboard layout */
}
if (mods & NSControlKeyMask) {
keyChar = [theEvent firstCharacterIgnoringModifiers]; /* first gets '\n' when control key is set, so fall back to ignoringModifiers */
}

if (keyChar == kNext_Tag || keyChar == kPrev_Tag) {

Expand All @@ -886,10 +894,11 @@ - (BOOL)performKeyEquivalent:(NSEvent *)theEvent {
return YES;
}
}

return [super performKeyEquivalent:theEvent];
}


- (void)incrementNoteSelection:(id)sender {

int tag = [sender tag];
Expand Down

0 comments on commit ef05b9a

Please sign in to comment.