<M-Up> and <M-Down> not triggered twice

The default Cocoa key bindings map these key presses to two commands
which led them to be triggered twice.  Avoid this by passing
Alt+Function key presses straight to Vim instead of to
interpretKeyEvents:.
This commit is contained in:
Bjorn Winckler
2008-01-23 19:39:13 +01:00
parent 807c425577
commit bc28f07b5e
2 changed files with 14 additions and 4 deletions
+7 -2
View File
@@ -261,11 +261,16 @@ enum {
//NSLog(@"%s %@", _cmd, event);
// HACK! If control modifier is held, don't pass the event along to
// interpretKeyEvents: since some keys are bound to multiple commands which
// means doCommandBySelector: is called several times.
// means doCommandBySelector: is called several times. Do the same for
// Alt+Function key presses (Alt+Up and Alt+Down are bound to two
// commands). This hack may break input management, but unless we can
// figure out a way to disable key bindings there seems little else to do.
//
// TODO: Figure out a way to disable Cocoa key bindings entirely, without
// affecting input management.
if ([event modifierFlags] & NSControlKeyMask) {
int flags = [event modifierFlags];
if ((flags & NSControlKeyMask) ||
((flags & NSAlternateKeyMask) && (flags & NSFunctionKeyMask))) {
NSString *unmod = [event charactersIgnoringModifiers];
if ([unmod length] == 1 && [unmod characterAtIndex:0] <= 0x7f
&& [unmod characterAtIndex:0] >= 0x60) {
+7 -2
View File
@@ -487,11 +487,16 @@ enum {
//NSLog(@"%s %@", _cmd, event);
// HACK! If control modifier is held, don't pass the event along to
// interpretKeyEvents: since some keys are bound to multiple commands which
// means doCommandBySelector: is called several times.
// means doCommandBySelector: is called several times. Do the same for
// Alt+Function key presses (Alt+Up and Alt+Down are bound to two
// commands). This hack may break input management, but unless we can
// figure out a way to disable key bindings there seems little else to do.
//
// TODO: Figure out a way to disable Cocoa key bindings entirely, without
// affecting input management.
if ([event modifierFlags] & NSControlKeyMask) {
int flags = [event modifierFlags];
if ((flags & NSControlKeyMask) ||
((flags & NSAlternateKeyMask) && (flags & NSFunctionKeyMask))) {
NSString *unmod = [event charactersIgnoringModifiers];
if ([unmod length] == 1 && [unmod characterAtIndex:0] <= 0x7f
&& [unmod characterAtIndex:0] >= 0x60) {