mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Intercept 'help' key presses and clear the NSHelpKeyMask modifier flag
git-svn-id: http://macvim.googlecode.com/svn/trunk@194 96c4425d-ca35-0410-94e5-3396d5c13a8f
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
/* vi:set ts=8 sts=4 sw=4 ft=objc:
|
||||
*
|
||||
* VIM - Vi IMproved by Bram Moolenaar
|
||||
* MacVim GUI port by Bjorn Winckler
|
||||
*
|
||||
* Do ":help uganda" in Vim to read copying and usage conditions.
|
||||
* Do ":help credits" in Vim to see a list of people who contributed.
|
||||
* See README.txt for an overview of the Vim source code.
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "MacVim.h"
|
||||
|
||||
|
||||
@interface MMApplication : NSApplication {
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,45 @@
|
||||
/* vi:set ts=8 sts=4 sw=4 ft=objc:
|
||||
*
|
||||
* VIM - Vi IMproved by Bram Moolenaar
|
||||
* MacVim GUI port by Bjorn Winckler
|
||||
*
|
||||
* Do ":help uganda" in Vim to read copying and usage conditions.
|
||||
* Do ":help credits" in Vim to see a list of people who contributed.
|
||||
* See README.txt for an overview of the Vim source code.
|
||||
*/
|
||||
|
||||
#import "MMApplication.h"
|
||||
|
||||
|
||||
|
||||
|
||||
@implementation MMApplication
|
||||
|
||||
- (void)sendEvent:(NSEvent *)event
|
||||
{
|
||||
NSEventType type = [event type];
|
||||
unsigned flags = [event modifierFlags];
|
||||
|
||||
// HACK! Intercept 'help' key presses and clear the 'help key flag', else
|
||||
// Cocoa turns the mouse cursor into a question mark and goes into 'context
|
||||
// help mode' (the keyDown: event itself never reaches the text view). By
|
||||
// clearing the 'help key flag' this event will be treated like a normal
|
||||
// key event.
|
||||
if ((NSKeyDown == type || NSKeyUp == type) && (flags & NSHelpKeyMask)) {
|
||||
flags &= ~NSHelpKeyMask;
|
||||
event = [NSEvent keyEventWithType:[event type]
|
||||
location:[event locationInWindow]
|
||||
modifierFlags:flags
|
||||
timestamp:[event timestamp]
|
||||
windowNumber:[event windowNumber]
|
||||
context:[event context]
|
||||
characters:[event characters]
|
||||
charactersIgnoringModifiers:[event charactersIgnoringModifiers]
|
||||
isARepeat:[event isARepeat]
|
||||
keyCode:[event keyCode]];
|
||||
}
|
||||
|
||||
[super sendEvent:event];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user