Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Fix shortcuts for menu options only in the context menu

Simon Döhlb6e0e0686dd9
diff --git a/editor/script/script_editor_plugin.cpp b/editor/script/script_editor_plugin.cpp
index a1f49c58e3d..c0c925e7bf6 100644
--- a/editor/script/script_editor_plugin.cpp
+++ b/editor/script/script_editor_plugin.cpp
@@ -3295,13 +3295,25 @@ void ScriptEditor::shortcut_input(const Ref<InputEvent> &p_event) {
document_list->goto_next_document(true);
accept_event();
}
- if (ED_IS_SHORTCUT("script_editor/move_document_up", p_event)) {
- _menu_option(FILE_MENU_MOVE_UP);
- accept_event();
- }
- if (ED_IS_SHORTCUT("script_editor/move_document_down", p_event)) {
- _menu_option(FILE_MENU_MOVE_DOWN);
- accept_event();
+
+ static const HashMap<String, int> shortcut_mappings = {
+ { "script_editor/close_other_tabs", FILE_MENU_CLOSE_OTHER_TABS },
+ { "script_editor/close_tabs_below", FILE_MENU_CLOSE_TABS_BELOW },
+ { "script_editor/close_docs", FILE_MENU_CLOSE_DOCS },
+ { "script_editor/copy_path", FILE_MENU_COPY_PATH },
+ { "script_editor/copy_uid", FILE_MENU_COPY_UID },
+ { "script_editor/show_in_file_system", FILE_MENU_SHOW_IN_FILE_SYSTEM },
+ { "script_editor/move_document_up", FILE_MENU_MOVE_UP },
+ { "script_editor/move_document_down", FILE_MENU_MOVE_DOWN },
+ { "script_editor/sort_documents", FILE_MENU_SORT },
+ };
+
+ for (const KeyValue<String, int> &E : shortcut_mappings) {
+ if (ED_IS_SHORTCUT(E.key, p_event)) {
+ _menu_option(E.value);
+ accept_event();
+ break;
+ }
}
if (p_event->is_echo()) {
@@ -4229,9 +4241,11 @@ ScriptEditor::ScriptEditor(const String &p_config_section, const String &p_cache
file_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_editor/close_file"), FILE_MENU_CLOSE);
file_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_editor/close_all"), FILE_MENU_CLOSE_ALL);
file_menu->get_popup()->add_separator();
- file_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_editor/reload_script_soft"), FILE_MENU_SOFT_RELOAD_TOOL);
- file_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_editor/run_file"), FILE_MENU_RUN);
- file_menu->get_popup()->add_separator();
+ if (this == script_editor) {
+ file_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_editor/reload_script_soft"), FILE_MENU_SOFT_RELOAD_TOOL);
+ file_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_editor/run_file"), FILE_MENU_RUN);
+ file_menu->get_popup()->add_separator();
+ }
file_menu->get_popup()->add_submenu_node_item(TTRC("Theme"), theme_submenu, FILE_MENU_THEME_SUBMENU);
file_menu->get_popup()->add_separator();
file_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_editor/toggle_files_panel"), FILE_MENU_TOGGLE_FILES_PANEL);