From 7b139e77e8f7eeeb678070ee8943ea9287f7202e Mon Sep 17 00:00:00 2001 From: Stanislav Labzyuk Date: Sun, 31 Jul 2022 23:35:03 +0700 Subject: [PATCH] Add spacebar for folding in the Create New Node window --- editor/create_dialog.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 0814d5b5ca3..4dc581fb5b7 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -291,12 +291,13 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const String p_type_category == TypeCategory::OTHER_TYPE; bool is_virtual = ClassDB::class_exists(p_type) && ClassDB::is_virtual(p_type); + r_item->set_meta(SNAME("__instantiable"), can_instantiate && !is_virtual); + if (can_instantiate && !is_virtual) { r_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, icon_fallback)); } else { r_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, "NodeDisabled")); r_item->set_custom_color(0, search_options->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); - r_item->set_selectable(0, false); } bool is_deprecated = EditorHelp::get_doc_data()->class_list[p_type].is_deprecated; @@ -395,6 +396,11 @@ void CreateDialog::_confirmed() { return; } + TreeItem *selected = search_options->get_selected(); + if (!selected->get_meta("__instantiable", true)) { + return; + } + { Ref f = FileAccess::open(EditorPaths::get_singleton()->get_project_settings_dir().path_join("create_recent." + base_type), FileAccess::WRITE); if (f.is_valid()) { @@ -421,7 +427,7 @@ void CreateDialog::_text_changed(const String &p_newtext) { void CreateDialog::_sbox_input(const Ref &p_ie) { Ref k = p_ie; - if (k.is_valid()) { + if (k.is_valid() && k->is_pressed()) { switch (k->get_keycode()) { case Key::UP: case Key::DOWN: @@ -430,6 +436,13 @@ void CreateDialog::_sbox_input(const Ref &p_ie) { search_options->gui_input(k); search_box->accept_event(); } break; + case Key::SPACE: { + TreeItem *ti = search_options->get_selected(); + if (ti) { + ti->set_collapsed(!ti->is_collapsed()); + } + search_box->accept_event(); + } break; default: break; }