Fix KeyRelease event with CMD key pressed (close #381)
Solution based on pull request #401
This commit is contained in:
parent
513cd7e57c
commit
fc63a727ce
@ -27,12 +27,13 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Event processing
|
/// \brief Event processing
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@interface SFApplication : NSObject
|
@interface SFApplication : NSApplication
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -42,4 +43,13 @@
|
|||||||
+(void)processEvent;
|
+(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
|
@end
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#import <SFML/Window/OSX/SFApplication.h>
|
#import <SFML/Window/OSX/SFApplication.h>
|
||||||
#import <AppKit/AppKit.h>
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -37,7 +36,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
+(void)processEvent
|
+(void)processEvent
|
||||||
{
|
{
|
||||||
[NSApplication sharedApplication]; // Make sure NSApp exists
|
[SFApplication sharedApplication]; // Make sure NSApp exists
|
||||||
NSEvent* event = nil;
|
NSEvent* event = nil;
|
||||||
|
|
||||||
while ((event = [NSApp nextEventMatchingMask:NSAnyEventMask
|
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
|
@end
|
||||||
|
|
||||||
|
@ -432,7 +432,7 @@
|
|||||||
[icon addRepresentation:bitmap];
|
[icon addRepresentation:bitmap];
|
||||||
|
|
||||||
// Set app icon.
|
// Set app icon.
|
||||||
[[NSApplication sharedApplication] setApplicationIconImage:icon];
|
[[SFApplication sharedApplication] setApplicationIconImage:icon];
|
||||||
|
|
||||||
// Free up.
|
// Free up.
|
||||||
[icon release];
|
[icon release];
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#import <SFML/Window/OSX/SFViewController.h>
|
#import <SFML/Window/OSX/SFViewController.h>
|
||||||
#import <SFML/Window/OSX/cpp_objc_conversion.h>
|
#import <SFML/Window/OSX/cpp_objc_conversion.h>
|
||||||
#import <SFML/Window/OSX/AutoreleasePoolWrapper.h>
|
#import <SFML/Window/OSX/AutoreleasePoolWrapper.h>
|
||||||
|
#import <SFML/Window/OSX/SFApplication.h>
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
{
|
{
|
||||||
@ -136,7 +137,7 @@ void WindowImplCocoa::setUpProcess(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tell the application to stop bouncing in the Dock.
|
// 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
|
// NOTE : This last call won't harm anything even if SFML window was
|
||||||
// created with an external handle.
|
// created with an external handle.
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user