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
|
while ((event = [NSApp nextEventMatchingMask:NSAnyEventMask
|
||||||
untilDate:[NSDate distantPast]
|
untilDate:[NSDate distantPast]
|
||||||
inMode:NSDefaultRunLoopMode
|
inMode:NSDefaultRunLoopMode
|
||||||
dequeue:YES])) // Remove the event from the dequeue
|
dequeue:YES])) // Remove the event from the queue
|
||||||
{
|
{
|
||||||
[NSApp sendEvent:event];
|
[NSApp sendEvent:event];
|
||||||
}
|
}
|
||||||
@ -50,9 +50,13 @@
|
|||||||
|
|
||||||
-(void)sendEvent:(NSEvent *)anEvent
|
-(void)sendEvent:(NSEvent *)anEvent
|
||||||
{
|
{
|
||||||
if ([anEvent type] == NSKeyUp) {
|
// Fullscreen windows have a strange behaviour with key up. To make
|
||||||
[[[self mainWindow] firstResponder] tryToPerform:@selector(keyUp:)
|
// sure the user gets an event we call (if possible) sfKeyUp on our
|
||||||
with:anEvent];
|
// 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 {
|
} else {
|
||||||
[super sendEvent:anEvent];
|
[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
|
// Transmit to non-SFML responder
|
||||||
[[self nextResponder] keyUp:theEvent];
|
[[self nextResponder] keyUp:theEvent];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user