Merge pull request #104628 from Calinou/editor-add-toggle-visibility-shortcut

Add `H` keyboard shortcut to toggle node visibility in the 2D and 3D editors
This commit is contained in:
Thaddeus Crews 2026-02-19 09:46:08 -06:00
commit 9a3a7f9abf
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
2 changed files with 22 additions and 1 deletions

View file

@ -427,6 +427,26 @@ void EditorNode::shortcut_input(const Ref<InputEvent> &p_event) {
_open_command_palette();
} else if (ED_IS_SHORTCUT("editor/toggle_last_opened_bottom_panel", p_event)) {
bottom_panel->toggle_last_opened_bottom_panel();
} else if (ED_IS_SHORTCUT("editor/toggle_selected_nodes_visibility", p_event)) {
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
undo_redo->create_action(TTR("Toggle Selected Node(s) Visibility"));
const List<Node *> &selection = editor_selection->get_top_selected_node_list();
for (Node *E : selection) {
Node *node_with_visibility;
node_with_visibility = Object::cast_to<CanvasItem>(E);
if (!node_with_visibility || !node_with_visibility->is_inside_tree()) {
node_with_visibility = Object::cast_to<Node3D>(E);
if (!node_with_visibility || !node_with_visibility->is_inside_tree()) {
continue;
}
}
undo_redo->add_do_method(node_with_visibility, "set_visible", !node_with_visibility->get("visible"));
undo_redo->add_undo_method(node_with_visibility, "set_visible", node_with_visibility->get("visible"));
}
undo_redo->commit_action();
} else {
is_handled = false;
}
@ -8259,6 +8279,7 @@ EditorNode::EditorNode() {
ED_SHORTCUT("editor/unlock_selected_nodes", TTRC("Unlock Selected Node(s)"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::L);
ED_SHORTCUT("editor/group_selected_nodes", TTRC("Group Selected Node(s)"), KeyModifierMask::CMD_OR_CTRL | Key::G);
ED_SHORTCUT("editor/ungroup_selected_nodes", TTRC("Ungroup Selected Node(s)"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::G);
ED_SHORTCUT("editor/toggle_selected_nodes_visibility", TTRC("Toggle Selected Node(s) Visibility"), Key::H);
FileAccess::set_backup_save(EDITOR_GET("filesystem/on_save/safe_save_on_backup_then_rename"));

View file

@ -5936,7 +5936,7 @@ CanvasItemEditor::CanvasItemEditor() {
grid_menu->add_shortcut(ED_SHORTCUT("canvas_item_editor/toggle_grid", TTRC("Toggle Grid"), KeyModifierMask::CMD_OR_CTRL | Key::APOSTROPHE));
p->add_submenu_node_item(TTRC("Grid"), grid_menu);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_helpers", TTRC("Show Helpers"), Key::H), SHOW_HELPERS);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_helpers", TTRC("Show Helpers"), KeyModifierMask::SHIFT | Key::H), SHOW_HELPERS);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_rulers", TTRC("Show Rulers")), SHOW_RULERS);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_guides", TTRC("Show Guides"), Key::Y), SHOW_GUIDES);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_origin", TTRC("Show Origin")), SHOW_ORIGIN);