macOS: Fix control+tab key combination not working

Fixes #801
This commit is contained in:
Kovid Goyal 2018-08-11 07:18:24 +05:30
parent acdb56ad5d
commit a143faaf05
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 31 additions and 9 deletions

View File

@ -56,6 +56,7 @@ Changelog
GPU machines. I give up, Apple users will just have to live with the
limitations of their choice of OS. (:iss:`794`)
- macOS: Fix control+tab key combination not working (:iss:`801`)
0.11.3 [2018-07-10]
------------------------------

View File

@ -1061,18 +1061,39 @@ is_ascii_control_char(char x) {
@implementation GLFWApplication
// From http://cocoadev.com/index.pl?GameKeyboardHandlingAlmost
// This works around an AppKit bug, where key up events while holding
// down the command key don't get sent to the key window.
- (void)sendEvent:(NSEvent *)event
{
if ([event type] == NSEventTypeKeyUp &&
([event modifierFlags] & NSEventModifierFlagCommand))
{
[[self keyWindow] sendEvent:event];
NSEventType etype = [event type];
NSEventModifierFlags flags;
switch(etype) {
case NSEventTypeKeyUp:
flags = [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
if (flags & NSEventModifierFlagCommand) {
// From http://cocoadev.com/index.pl?GameKeyboardHandlingAlmost
// This works around an AppKit bug, where key up events while holding
// down the command key don't get sent to the key window.
[[self keyWindow] sendEvent:event];
return;
}
if (flags == NSEventModifierFlagControl && event.keyCode == kVK_Tab) {
// Cocoa swallows Ctrl+Tab to cycle between views
[[self keyWindow].contentView keyUp:event];
return;
}
break;
case NSEventTypeKeyDown:
flags = [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
if (flags == NSEventModifierFlagControl && event.keyCode == kVK_Tab) {
// Cocoa swallows Ctrl+Tab to cycle between views
[[self keyWindow].contentView keyDown:event];
return;
}
break;
default:
break;
}
else
[super sendEvent:event];
[super sendEvent:event];
}