diff options
Diffstat (limited to 'editor/property_selector.cpp')
-rw-r--r-- | editor/property_selector.cpp | 53 |
1 files changed, 22 insertions, 31 deletions
diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 8f609850b8..67a72f746e 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -30,49 +30,38 @@ #include "property_selector.h" -#include "core/os/keyboard.h" -#include "editor/doc_tools.h" #include "editor/editor_help.h" #include "editor/editor_node.h" #include "editor/themes/editor_scale.h" #include "scene/gui/line_edit.h" -#include "scene/gui/rich_text_label.h" #include "scene/gui/tree.h" void PropertySelector::_text_changed(const String &p_newtext) { _update_search(); } -void PropertySelector::_sbox_input(const Ref<InputEvent> &p_ie) { - Ref<InputEventKey> k = p_ie; - - if (k.is_valid()) { - switch (k->get_keycode()) { - case Key::UP: - case Key::DOWN: - case Key::PAGEUP: - case Key::PAGEDOWN: { - search_options->gui_input(k); - search_box->accept_event(); - - TreeItem *root = search_options->get_root(); - if (!root->get_first_child()) { - break; - } - - TreeItem *current = search_options->get_selected(); +void PropertySelector::_sbox_input(const Ref<InputEvent> &p_event) { + // Redirect navigational key events to the tree. + Ref<InputEventKey> key = p_event; + if (key.is_valid()) { + if (key->is_action("ui_up", true) || key->is_action("ui_down", true) || key->is_action("ui_page_up") || key->is_action("ui_page_down")) { + search_options->gui_input(key); + search_box->accept_event(); + + TreeItem *root = search_options->get_root(); + if (!root->get_first_child()) { + return; + } - TreeItem *item = search_options->get_next_selected(root); - while (item) { - item->deselect(0); - item = search_options->get_next_selected(item); - } + TreeItem *current = search_options->get_selected(); - current->select(0); + TreeItem *item = search_options->get_next_selected(root); + while (item) { + item->deselect(0); + item = search_options->get_next_selected(item); + } - } break; - default: - break; + current->select(0); } } } @@ -330,7 +319,7 @@ void PropertySelector::_update_search() { } } - get_ok_button()->set_disabled(root->get_first_child() == nullptr); + get_ok_button()->set_disabled(search_options->get_selected() == nullptr); } void PropertySelector::_confirmed() { @@ -346,6 +335,8 @@ void PropertySelector::_item_selected() { help_bit->set_custom_text(String(), String(), String()); TreeItem *item = search_options->get_selected(); + get_ok_button()->set_disabled(item == nullptr); + if (!item) { return; } |