Skip to content

Commit

Permalink
Fix Ctrl+Tab and Ctrl+Shift+Tab on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
passivestar committed Feb 14, 2024
1 parent 907db8e commit 757a691
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
4 changes: 2 additions & 2 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6767,8 +6767,8 @@ EditorNode::EditorNode() {
warning->add_button(TTR("Copy Text"), true, "copy");
warning->connect("custom_action", callable_mp(this, &EditorNode::_copy_warning));

ED_SHORTCUT("editor/next_tab", TTR("Next Scene Tab"), KeyModifierMask::CMD_OR_CTRL + Key::TAB);
ED_SHORTCUT("editor/prev_tab", TTR("Previous Scene Tab"), KeyModifierMask::CMD_OR_CTRL + KeyModifierMask::SHIFT + Key::TAB);
ED_SHORTCUT("editor/next_tab", TTR("Next Scene Tab"), KeyModifierMask::CTRL + Key::TAB);
ED_SHORTCUT("editor/prev_tab", TTR("Previous Scene Tab"), KeyModifierMask::CTRL + KeyModifierMask::SHIFT + Key::TAB);
ED_SHORTCUT("editor/filter_files", TTR("Focus FileSystem Filter"), KeyModifierMask::CMD_OR_CTRL + KeyModifierMask::ALT + Key::P);

command_palette = EditorCommandPalette::get_singleton();
Expand Down
26 changes: 23 additions & 3 deletions platform/macos/display_server_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,12 @@
}

void DisplayServerMacOS::send_event(NSEvent *p_event) {
// Special case handling of command-period, which is traditionally a special
// shortcut in macOS and doesn't arrive at our regular keyDown handler.
// Special case handling of shortcuts that don't arrive at the regular keyDown handler
if ([p_event type] == NSEventTypeKeyDown) {
if ((([p_event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask) == NSEventModifierFlagCommand) && [p_event keyCode] == 0x2f) {
NSEventModifierFlags flags = [p_event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;

// Command-period
if ((flags == NSEventModifierFlagCommand) && [p_event keyCode] == 0x2f) {
Ref<InputEventKey> k;
k.instantiate();

Expand All @@ -715,6 +717,24 @@
k->set_echo([p_event isARepeat]);

Input::get_singleton()->parse_input_event(k);
return;
}

// Ctrl+Tab and Ctrl+Shift+Tab
if (((flags == NSEventModifierFlagControl) || (flags == (NSEventModifierFlagControl | NSEventModifierFlagShift))) && [p_event keyCode] == 0x30) {
Ref<InputEventKey> k;
k.instantiate();

get_key_modifier_state([p_event modifierFlags], k);
k->set_window_id(DisplayServerMacOS::INVALID_WINDOW_ID);
k->set_pressed(true);
k->set_keycode(Key::TAB);
k->set_physical_keycode(Key::TAB);
k->set_key_label(Key::TAB);
k->set_echo([p_event isARepeat]);

Input::get_singleton()->parse_input_event(k);
return;
}
}
}
Expand Down

0 comments on commit 757a691

Please sign in to comment.