summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-01-04 14:56:29 +0100
committerGitHub <noreply@github.com>2018-01-04 14:56:29 +0100
commitb997773b26ec944c4bc73a54aca8c9ccfe6d1119 (patch)
tree0701ad9fd6831e28a691c10dd4e15ab6e137c480 /platform
parentdc2cc6bc2b2c5ca770675267bff98f434566866b (diff)
parent3f122672a2fb188f7d05c6e9b0a3e1125fb2c4f1 (diff)
Merge pull request #15033 from poke1024/shortcuts-mac
Alternative keyboard shortcuts for macOS
Diffstat (limited to 'platform')
-rw-r--r--platform/osx/os_osx.mm24
1 files changed, 21 insertions, 3 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 99c5995d7a..dbc9cdf3b7 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -99,10 +99,28 @@ static Vector2 get_mouse_pos(NSEvent *event) {
@implementation GodotApplication
-// 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 {
+
+ // special case handling of command-period, which is traditionally a special
+ // shortcut in macOS and doesn't arrive at our regular keyDown handler.
+ if ([event type] == NSKeyDown) {
+ if (([event modifierFlags] & NSEventModifierFlagCommand) && [event keyCode] == 0x2f) {
+
+ Ref<InputEventKey> k;
+ k.instance();
+
+ get_key_modifier_state([event modifierFlags], k);
+ k->set_pressed(true);
+ k->set_scancode(KEY_PERIOD);
+ k->set_echo([event isARepeat]);
+
+ OS_OSX::singleton->push_input(k);
+ }
+ }
+
+ // 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.
if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask))
[[self keyWindow] sendEvent:event];
else