1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Merge pull request #96400 from Maran23/inputmap-usage-for-filter-and-corresponding-refactor

Use InputMap actions consistently across all LineEdit's that filter an underlying Tree or ItemList.
This commit is contained in:
Rémi Verschelde
2024-09-16 13:34:38 +02:00
23 changed files with 140 additions and 205 deletions

View File

@@ -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;
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();
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()) {
return;
}
TreeItem *root = search_options->get_root();
if (!root->get_first_child()) {
break;
}
TreeItem *current = search_options->get_selected();
TreeItem *current = search_options->get_selected();
TreeItem *item = search_options->get_next_selected(root);
while (item) {
item->deselect(0);
item = search_options->get_next_selected(item);
}
TreeItem *item = search_options->get_next_selected(root);
while (item) {
item->deselect(0);
item = search_options->get_next_selected(item);
}
current->select(0);
} 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;
}