From b434df6061c5436685d2fd6f24e8ebeaf619311f Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Tue, 16 Feb 2010 07:27:55 +0000 Subject: changed events dispatching so command+key generates both FL_KEYBOARD and FL_KEYUP events git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7087 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_cocoa.mm | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index d0da4dbfb..1fc5f5ce2 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -1391,6 +1391,29 @@ extern "C" { } @end +@interface FLApplication : NSApplication +{ +} +- (void)sendEvent:(NSEvent *)theEvent; +@end +@implementation FLApplication +// The default sendEvent turns key downs into performKeyEquivalent when +// modifiers are down, but swallows the key up if the modifiers include +// command. This one makes all modifiers consistent by always sending key ups. +// FLView treats performKeyEquivalent to keyDown, but performKeyEquivalent is +// still needed for the system menu. +- (void)sendEvent:(NSEvent *)theEvent +{ + NSEventType type = [theEvent type]; + NSWindow *key = [self keyWindow]; + if (key && type == NSKeyUp) { + [key sendEvent:theEvent]; + } else { + [super sendEvent:theEvent]; + } +} +@end + static FLDelegate *mydelegate; void fl_open_display() { @@ -1398,7 +1421,7 @@ void fl_open_display() { if ( !beenHereDoneThat ) { beenHereDoneThat = 1; - [NSApplication sharedApplication]; + [FLApplication sharedApplication]; NSAutoreleasePool *localPool; localPool = [[NSAutoreleasePool alloc] init]; mydelegate = [[FLDelegate alloc] init]; -- cgit v1.2.3