Fixed Command key up on Mac OS X. This fix also fixes Help key down, so remove the workaround there.
This commit is contained in:
parent
fe4d9b992d
commit
9f2669d583
|
@ -101,6 +101,13 @@ event(flagsChanged, areaView_flagsChanged)
|
|||
|
||||
@end
|
||||
|
||||
Class areaClass;
|
||||
|
||||
void initAreaClass(void)
|
||||
{
|
||||
areaClass = [areaView class];
|
||||
}
|
||||
|
||||
id makeArea(void)
|
||||
{
|
||||
return [[areaView alloc]
|
||||
|
|
|
@ -35,10 +35,47 @@
|
|||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <AppKit/NSEvent.h>
|
||||
#import <AppKit/NSAlert.h>
|
||||
#import <AppKit/NSHelpManager.h>
|
||||
|
||||
extern NSRect dummyRect;
|
||||
|
||||
@interface ourApplication : NSApplication
|
||||
@end
|
||||
|
||||
@implementation ourApplication
|
||||
|
||||
// by default, NSApplication eats some key events
|
||||
// this prevents that from happening with Area
|
||||
// see http://stackoverflow.com/questions/24099063/how-do-i-detect-keyup-in-my-nsview-with-the-command-key-held and http://lists.apple.com/archives/cocoa-dev/2003/Oct/msg00442.html
|
||||
- (void)sendEvent:(NSEvent *)e
|
||||
{
|
||||
NSEventType type;
|
||||
|
||||
type = [e type];
|
||||
if (type == NSKeyDown || type == NSKeyUp || type == NSFlagsChanged) {
|
||||
id focused;
|
||||
|
||||
focused = [[e window] firstResponder];
|
||||
// TODO can focused be nil? the isKindOfClass: docs don't say if it handles nil receivers
|
||||
if ([focused isKindOfClass:areaClass])
|
||||
switch (type) {
|
||||
case NSKeyDown:
|
||||
[focused keyDown:e];
|
||||
return;
|
||||
case NSKeyUp:
|
||||
[focused keyUp:e];
|
||||
return;
|
||||
case NSFlagsChanged:
|
||||
[focused flagsChanged:e];
|
||||
return;
|
||||
}
|
||||
// else fall through
|
||||
}
|
||||
// otherwise, let NSApplication do it
|
||||
[super sendEvent:e];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface appDelegate : NSObject
|
||||
@end
|
||||
|
||||
|
@ -75,13 +112,6 @@ extern NSRect dummyRect;
|
|||
{
|
||||
}
|
||||
|
||||
// see below
|
||||
// TODO is this the correct signature?
|
||||
- (void)helpbreaker:(NSNotification *)n
|
||||
{
|
||||
[NSHelpManager setContextHelpModeActive:NO];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
id makeAppDelegate(void)
|
||||
|
@ -97,19 +127,12 @@ id windowGetContentView(id window)
|
|||
BOOL initCocoa(id appDelegate)
|
||||
{
|
||||
dummyRect = NSMakeRect(0, 0, 100, 100);
|
||||
[NSApplication sharedApplication];
|
||||
initAreaClass();
|
||||
[ourApplication sharedApplication]; // makes NSApp an object of type ourApplication
|
||||
if ([NSApp setActivationPolicy:NSApplicationActivationPolicyRegular] != YES)
|
||||
return NO;
|
||||
[NSApp activateIgnoringOtherApps:YES]; // TODO actually do C.NO here? Russ Cox does YES in his devdraw; the docs say the Finder does NO
|
||||
[NSApp setDelegate:appDelegate];
|
||||
// by default, Mac OS X intercepts Help key keyDown events
|
||||
// we treat Help as Insert, so we don't want this behavior
|
||||
// this will override it; see http://stackoverflow.com/a/4078542/3408572
|
||||
// TODO this doesn't send keyDown:
|
||||
[[NSNotificationCenter defaultCenter] addObserver:appDelegate
|
||||
selector:@selector(helpbreaker:)
|
||||
name:NSContextHelpModeDidActivateNotification
|
||||
object:nil];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ extern void giveScrollViewBezelBorder(id);
|
|||
extern id scrollViewContent(id);
|
||||
|
||||
/* area_darwin.m */
|
||||
extern Class areaClass;
|
||||
extern void initAreaClass(void);
|
||||
extern id makeArea(void);
|
||||
extern void drawImage(void *, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t);
|
||||
extern uintptr_t modifierFlags(id);
|
||||
|
|
Loading…
Reference in New Issue