Skip to content

Commit b3de23f

Browse files
committed
Merge pull request #109234 from kushagra10025/main-screen-plugin-shortcuts
Add Shortcut tooltip to Editor Main Screen Plugins
2 parents ec3f304 + 4bb188f commit b3de23f

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

editor/editor_main_screen.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ void EditorMainScreen::add_main_plugin(EditorPlugin *p_editor) {
263263
tb->set_name(p_editor->get_plugin_name());
264264
tb->set_text(p_editor->get_plugin_name());
265265

266+
Ref<Shortcut> shortcut = EditorSettings::get_singleton()->get_shortcut("editor/editor_" + p_editor->get_plugin_name().to_lower());
267+
if (shortcut.is_valid()) {
268+
tb->set_shortcut(shortcut);
269+
}
270+
266271
Ref<Texture2D> icon = p_editor->get_plugin_icon();
267272
if (icon.is_null() && has_theme_icon(p_editor->get_plugin_name(), EditorStringName(EditorIcons))) {
268273
icon = get_editor_theme_icon(p_editor->get_plugin_name());

editor/editor_node.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8651,6 +8651,22 @@ EditorNode::EditorNode() {
86518651
}
86528652
help_menu->add_icon_shortcut(get_editor_theme_native_menu_icon(SNAME("Heart"), global_menu, dark_mode), ED_SHORTCUT_AND_COMMAND("editor/support_development", TTRC("Support Godot Development")), HELP_SUPPORT_GODOT_DEVELOPMENT);
86538653

8654+
// Use the Ctrl modifier so F2 can be used to rename nodes in the scene tree dock.
8655+
ED_SHORTCUT_AND_COMMAND("editor/editor_2d", TTRC("Open 2D Workspace"), KeyModifierMask::CTRL | Key::F1);
8656+
ED_SHORTCUT_AND_COMMAND("editor/editor_3d", TTRC("Open 3D Workspace"), KeyModifierMask::CTRL | Key::F2);
8657+
ED_SHORTCUT_AND_COMMAND("editor/editor_script", TTRC("Open Script Editor"), KeyModifierMask::CTRL | Key::F3);
8658+
ED_SHORTCUT_AND_COMMAND("editor/editor_game", TTRC("Open Game View"), KeyModifierMask::CTRL | Key::F4);
8659+
ED_SHORTCUT_AND_COMMAND("editor/editor_assetlib", TTRC("Open Asset Library"), KeyModifierMask::CTRL | Key::F5);
8660+
8661+
ED_SHORTCUT_OVERRIDE("editor/editor_2d", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::KEY_1);
8662+
ED_SHORTCUT_OVERRIDE("editor/editor_3d", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::KEY_2);
8663+
ED_SHORTCUT_OVERRIDE("editor/editor_script", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::KEY_3);
8664+
ED_SHORTCUT_OVERRIDE("editor/editor_game", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::KEY_4);
8665+
ED_SHORTCUT_OVERRIDE("editor/editor_assetlib", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::KEY_5);
8666+
8667+
ED_SHORTCUT_AND_COMMAND("editor/editor_next", TTRC("Open the next Editor"));
8668+
ED_SHORTCUT_AND_COMMAND("editor/editor_prev", TTRC("Open the previous Editor"));
8669+
86548670
// Spacer to center 2D / 3D / Script buttons.
86558671
right_spacer = memnew(Control);
86568672
right_spacer->set_mouse_filter(Control::MOUSE_FILTER_PASS);
@@ -9159,22 +9175,6 @@ EditorNode::EditorNode() {
91599175
ResourceSaver::set_save_callback(_resource_saved);
91609176
ResourceLoader::set_load_callback(_resource_loaded);
91619177

9162-
// Use the Ctrl modifier so F2 can be used to rename nodes in the scene tree dock.
9163-
ED_SHORTCUT_AND_COMMAND("editor/editor_2d", TTRC("Open 2D Editor"), KeyModifierMask::CTRL | Key::F1);
9164-
ED_SHORTCUT_AND_COMMAND("editor/editor_3d", TTRC("Open 3D Editor"), KeyModifierMask::CTRL | Key::F2);
9165-
ED_SHORTCUT_AND_COMMAND("editor/editor_script", TTRC("Open Script Editor"), KeyModifierMask::CTRL | Key::F3);
9166-
ED_SHORTCUT_AND_COMMAND("editor/editor_game", TTRC("Open Game View"), KeyModifierMask::CTRL | Key::F4);
9167-
ED_SHORTCUT_AND_COMMAND("editor/editor_assetlib", TTRC("Open Asset Library"), KeyModifierMask::CTRL | Key::F5);
9168-
9169-
ED_SHORTCUT_OVERRIDE("editor/editor_2d", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::KEY_1);
9170-
ED_SHORTCUT_OVERRIDE("editor/editor_3d", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::KEY_2);
9171-
ED_SHORTCUT_OVERRIDE("editor/editor_script", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::KEY_3);
9172-
ED_SHORTCUT_OVERRIDE("editor/editor_game", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::KEY_4);
9173-
ED_SHORTCUT_OVERRIDE("editor/editor_assetlib", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::KEY_5);
9174-
9175-
ED_SHORTCUT_AND_COMMAND("editor/editor_next", TTRC("Open the next Editor"));
9176-
ED_SHORTCUT_AND_COMMAND("editor/editor_prev", TTRC("Open the previous Editor"));
9177-
91789178
// Apply setting presets in case the editor_settings file is missing values.
91799179
EditorSettingsDialog::update_navigation_preset();
91809180

0 commit comments

Comments
 (0)