mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Fix Key Released events in fullscreen (close #465)
This commit is contained in:
parent
1b113c2c22
commit
e5c6f6cd7a
@ -42,7 +42,7 @@
|
||||
while ((event = [NSApp nextEventMatchingMask:NSAnyEventMask
|
||||
untilDate:[NSDate distantPast]
|
||||
inMode:NSDefaultRunLoopMode
|
||||
dequeue:YES])) // Remove the event from the dequeue
|
||||
dequeue:YES])) // Remove the event from the queue
|
||||
{
|
||||
[NSApp sendEvent:event];
|
||||
}
|
||||
@ -50,9 +50,13 @@
|
||||
|
||||
-(void)sendEvent:(NSEvent *)anEvent
|
||||
{
|
||||
if ([anEvent type] == NSKeyUp) {
|
||||
[[[self mainWindow] firstResponder] tryToPerform:@selector(keyUp:)
|
||||
with:anEvent];
|
||||
// Fullscreen windows have a strange behaviour with key up. To make
|
||||
// sure the user gets an event we call (if possible) sfKeyUp on our
|
||||
// custom OpenGL view. See -[SFOpenGLView sfKeyUp:] for more details.
|
||||
|
||||
id firstResponder = [[anEvent window] firstResponder];
|
||||
if ([anEvent type] == NSKeyUp && [firstResponder respondsToSelector:@selector(sfKeyUp:)]) {
|
||||
[firstResponder sfKeyUp:anEvent];
|
||||
} else {
|
||||
[super sendEvent:anEvent];
|
||||
}
|
||||
|
@ -619,8 +619,15 @@ BOOL isValidTextUnicode(NSEvent* event);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
-(void)keyUp:(NSEvent *)theEvent
|
||||
-(void)sfKeyUp:(NSEvent *)theEvent
|
||||
{
|
||||
// For some mystic reasons, key released events don't work the same way
|
||||
// as key pressed events... We somewhat hijack the event chain of response
|
||||
// in -[SFApplication sendEvent:] and resume this chain with the next
|
||||
// responder.
|
||||
// This is workaround to make sure key released events are fired in
|
||||
// fullscreen window too.
|
||||
|
||||
// Transmit to non-SFML responder
|
||||
[[self nextResponder] keyUp:theEvent];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user