From 20887d801bf116d04b449824dcae4694ca946b50 Mon Sep 17 00:00:00 2001 From: Kevin Cardona Date: Sat, 16 Sep 2023 15:30:37 -0600 Subject: [PATCH 1/2] Allow editor commands to have multiple default commands --- editor/editor_command_palette.cpp | 10 ++++++++++ editor/editor_command_palette.h | 1 + 2 files changed, 11 insertions(+) diff --git a/editor/editor_command_palette.cpp b/editor/editor_command_palette.cpp index 168fe5a7ace..18a251a306b 100644 --- a/editor/editor_command_palette.cpp +++ b/editor/editor_command_palette.cpp @@ -357,3 +357,13 @@ Ref ED_SHORTCUT_AND_COMMAND(const String &p_path, const String &p_name EditorCommandPalette::get_singleton()->add_shortcut_command(p_command_name, p_path, shortcut); return shortcut; } + +Ref ED_SHORTCUT_ARRAY_AND_COMMAND(const String &p_path, const String &p_name, const PackedInt32Array &p_keycodes, String p_command_name) { + if (p_command_name.is_empty()) { + p_command_name = p_name; + } + + Ref shortcut = ED_SHORTCUT_ARRAY(p_path, p_name, p_keycodes); + EditorCommandPalette::get_singleton()->add_shortcut_command(p_command_name, p_path, shortcut); + return shortcut; +} diff --git a/editor/editor_command_palette.h b/editor/editor_command_palette.h index 7eb9ff74045..b34c4ddf971 100644 --- a/editor/editor_command_palette.h +++ b/editor/editor_command_palette.h @@ -105,5 +105,6 @@ public: }; Ref ED_SHORTCUT_AND_COMMAND(const String &p_path, const String &p_name, Key p_keycode = Key::NONE, String p_command = ""); +Ref ED_SHORTCUT_ARRAY_AND_COMMAND(const String &p_path, const String &p_name, const PackedInt32Array &p_keycodes, String p_command = ""); #endif // EDITOR_COMMAND_PALETTE_H From c1146632b2e0b891ba762672a5b15aef3ddb281d Mon Sep 17 00:00:00 2001 From: Kevin Cardona Date: Sat, 16 Sep 2023 15:32:37 -0600 Subject: [PATCH 2/2] Add Ctrl/CMD+P as a shortcut to quick open files in addition to Shift+Alt+O --- editor/editor_node.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 5341d73fe43..223e50f557f 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -7226,8 +7226,8 @@ EditorNode::EditorNode() { file_menu->add_separator(); - file_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/quick_open", TTR("Quick Open..."), KeyModifierMask::SHIFT + KeyModifierMask::ALT + Key::O), FILE_QUICK_OPEN); - ED_SHORTCUT_OVERRIDE("editor/quick_open", "macos", KeyModifierMask::META + KeyModifierMask::CTRL + Key::O); + file_menu->add_shortcut(ED_SHORTCUT_ARRAY_AND_COMMAND("editor/quick_open", TTR("Quick Open..."), { int32_t(KeyModifierMask::SHIFT + KeyModifierMask::ALT + Key::O), int32_t(KeyModifierMask::CMD_OR_CTRL + Key::P) }), FILE_QUICK_OPEN); + ED_SHORTCUT_OVERRIDE_ARRAY("editor/quick_open", "macos", { int32_t(KeyModifierMask::META + KeyModifierMask::CTRL + Key::O), int32_t(KeyModifierMask::CMD_OR_CTRL + Key::P) }); file_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/quick_open_scene", TTR("Quick Open Scene..."), KeyModifierMask::CMD_OR_CTRL + KeyModifierMask::SHIFT + Key::O), FILE_QUICK_OPEN_SCENE); file_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/quick_open_script", TTR("Quick Open Script..."), KeyModifierMask::CMD_OR_CTRL + KeyModifierMask::ALT + Key::O), FILE_QUICK_OPEN_SCRIPT);