Skip to content

Commit

Permalink
changed events dispatching so command+key generates both FL_KEYBOARD …
Browse files Browse the repository at this point in the history
…and FL_KEYUP events

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7087 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Feb 16, 2010
1 parent 5a76896 commit b434df6
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/Fl_cocoa.mm
Expand Up @@ -1391,14 +1391,37 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender
}
@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() {
static char beenHereDoneThat = 0;
if ( !beenHereDoneThat ) {
beenHereDoneThat = 1;

[NSApplication sharedApplication];
[FLApplication sharedApplication];
NSAutoreleasePool *localPool;
localPool = [[NSAutoreleasePool alloc] init];
mydelegate = [[FLDelegate alloc] init];
Expand Down

0 comments on commit b434df6

Please sign in to comment.