mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
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:
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user