1 /* vi:set ts=8 sts=4 sw=4 ft=objc:
3 * VIM - Vi IMproved by Bram Moolenaar
4 * MacVim GUI port by Bjorn Winckler
6 * Do ":help uganda" in Vim to read copying and usage conditions.
7 * Do ":help credits" in Vim to see a list of people who contributed.
8 * See README.txt for an overview of the Vim source code.
13 * Some default NSApplication key input behavior is overridden here.
16 #import "MMApplication.h"
18 // Ctrl-Tab is broken on pre 10.5, so we add a hack to make it work.
19 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
20 # import "MMTextView.h"
21 # define MM_CTRL_TAB_HACK 1
27 @implementation MMApplication
29 - (void)sendEvent:(NSEvent *)event
31 NSEventType type = [event type];
32 unsigned flags = [event modifierFlags];
34 #ifdef MM_CTRL_TAB_HACK
35 NSResponder *firstResponder = [[self keyWindow] firstResponder];
37 if (NSKeyDown == type && NSControlKeyMask & flags && 48 == [event keyCode]
38 && [firstResponder isKindOfClass:[MMTextView class]]) {
39 // HACK! This is a Ctrl-Tab key down event and the first responder is
40 // an MMTextView; send the event directly to the text view, else it
41 // will never receive it on pre 10.5 systems.
42 [firstResponder keyDown:event];
47 // HACK! Intercept 'help' key presses and clear the 'help key flag', else
48 // Cocoa turns the mouse cursor into a question mark and goes into 'context
49 // help mode' (the keyDown: event itself never reaches the text view). By
50 // clearing the 'help key flag' this event will be treated like a normal
52 if ((NSKeyDown == type || NSKeyUp == type) && (flags & NSHelpKeyMask)) {
53 flags &= ~NSHelpKeyMask;
54 event = [NSEvent keyEventWithType:[event type]
55 location:[event locationInWindow]
57 timestamp:[event timestamp]
58 windowNumber:[event windowNumber]
59 context:[event context]
60 characters:[event characters]
61 charactersIgnoringModifiers:[event charactersIgnoringModifiers]
62 isARepeat:[event isARepeat]
63 keyCode:[event keyCode]];
66 [super sendEvent:event];