diff --git a/src/SFML/Window/OSX/SFApplication.h b/src/SFML/Window/OSX/SFApplication.h index f68c00559..2abbca2e9 100644 --- a/src/SFML/Window/OSX/SFApplication.h +++ b/src/SFML/Window/OSX/SFApplication.h @@ -27,12 +27,13 @@ // Headers //////////////////////////////////////////////////////////// #import +#import //////////////////////////////////////////////////////////// /// \brief Event processing /// //////////////////////////////////////////////////////////// -@interface SFApplication : NSObject +@interface SFApplication : NSApplication //////////////////////////////////////////////////////////// @@ -42,4 +43,13 @@ +(void)processEvent; +//////////////////////////////////////////////////////////// +/// \brief Dispatch events +/// +/// This overload of -[NSApplication sendEvent:] is used to +/// fix KeyRelease events when the command key is down. +//////////////////////////////////////////////////////////// +-(void)sendEvent:(NSEvent *)anEvent; + + @end diff --git a/src/SFML/Window/OSX/SFApplication.m b/src/SFML/Window/OSX/SFApplication.m index 75b01c5aa..a8bd3e4c3 100644 --- a/src/SFML/Window/OSX/SFApplication.m +++ b/src/SFML/Window/OSX/SFApplication.m @@ -27,7 +27,6 @@ // Headers //////////////////////////////////////////////////////////// #import -#import //////////////////////////////////////////////////////////// @@ -37,7 +36,7 @@ //////////////////////////////////////////////////////////// +(void)processEvent { - [NSApplication sharedApplication]; // Make sure NSApp exists + [SFApplication sharedApplication]; // Make sure NSApp exists NSEvent* event = nil; while ((event = [NSApp nextEventMatchingMask:NSAnyEventMask @@ -49,6 +48,16 @@ } } +- (void)sendEvent:(NSEvent *)anEvent +{ + if ([anEvent type] == NSKeyUp) { + [[[self mainWindow] firstResponder] tryToPerform:@selector(keyUp:) + with:anEvent]; + } else { + [super sendEvent:anEvent]; + } +} + @end diff --git a/src/SFML/Window/OSX/SFWindowController.mm b/src/SFML/Window/OSX/SFWindowController.mm index c572a2437..f3397b4bc 100644 --- a/src/SFML/Window/OSX/SFWindowController.mm +++ b/src/SFML/Window/OSX/SFWindowController.mm @@ -432,7 +432,7 @@ [icon addRepresentation:bitmap]; // Set app icon. - [[NSApplication sharedApplication] setApplicationIconImage:icon]; + [[SFApplication sharedApplication] setApplicationIconImage:icon]; // Free up. [icon release]; diff --git a/src/SFML/Window/OSX/WindowImplCocoa.mm b/src/SFML/Window/OSX/WindowImplCocoa.mm index 210daf526..ca5c01bdc 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.mm +++ b/src/SFML/Window/OSX/WindowImplCocoa.mm @@ -34,6 +34,7 @@ #import #import #import +#import namespace sf { @@ -136,7 +137,7 @@ void WindowImplCocoa::setUpProcess(void) } // Tell the application to stop bouncing in the Dock. - [[NSApplication sharedApplication] finishLaunching]; + [[SFApplication sharedApplication] finishLaunching]; // NOTE : This last call won't harm anything even if SFML window was // created with an external handle. }