Key down events in which Ctrl, Alt, or Command is held are immediately sent off to Vim instead of to interpretKeyEvents:. This is an attempt to bypass Key Bindings in Cocoa, since some key bindings cause several doCommandBySelector: messages to be sent (which means the key gets repeated). This fixed the CTRL-O bug in insert mode.

git-svn-id: http://macvim.googlecode.com/svn/trunk@111 96c4425d-ca35-0410-94e5-3396d5c13a8f
This commit is contained in:
Bjorn Winckler
2007-08-09 18:25:16 +00:00
parent ddc4ed0b35
commit 9b9a6096ed
+17
View File
@@ -80,6 +80,7 @@
// We usually end up here if the user pressed Ctrl+key (but not
// Ctrl+Option+key).
//NSLog(@"%s%@", _cmd, NSStringFromSelector(selector));
[self dispatchKeyEvent:[NSApp currentEvent]];
}
@@ -387,6 +388,21 @@
return YES;
}
- (void)keyDown:(NSEvent *)event
{
// HACK! If a 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.
//
// TODO: Figure out a way to disable Cocoa key bindings entirely.
if ([event modifierFlags] &
(NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask))
[self dispatchKeyEvent:event];
else
[super keyDown:event];
}
- (void)dispatchKeyEvent:(NSEvent *)event
{
// Only handle the command if it came from a keyDown event
@@ -431,6 +447,7 @@
[NSCursor setHiddenUntilMouseMoves:YES];
//NSLog(@"%s len=%d bytes=0x%x", _cmd, len, bytes[0]);
[[self vimController] sendMessage:KeyDownMsgID data:data wait:NO];
}
}