1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-20 14:45:44 +00:00

Use InputMap actions consistently across all LineEdit's that filter an underlying Tree or ItemList.

- Instead of checking for Key::UP, Key::DOWN, Key::PAGEUP, Key::PAGEDOWN etc., we rather check for the action like 'ui_up' or 'ui_down'.
- Also use AcceptDialog's 'register_text_enter' functionality to consistently close a dialog when ENTER is pressed while the LineEdit has focus (instead of redirecting ENTER keys to e.g. the underlying Tree).
- Unify the LineEdit filter behavior for the SceneTreeDialog and corresponding usages
- Improve OK Button disablement (something should be selected)
This commit is contained in:
Marius Hanl
2024-08-31 19:23:34 +02:00
parent 61598c5c88
commit 74f64aaf98
23 changed files with 140 additions and 205 deletions

View File

@@ -1744,6 +1744,17 @@ void SceneTreeDialog::_filter_changed(const String &p_filter) {
tree->set_filter(p_filter);
}
void SceneTreeDialog::_on_filter_gui_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")) {
tree->get_scene_tree()->gui_input(key);
filter->accept_event();
}
}
}
void SceneTreeDialog::_bind_methods() {
ClassDB::bind_method("_cancel", &SceneTreeDialog::_cancel);
@@ -1764,6 +1775,10 @@ SceneTreeDialog::SceneTreeDialog() {
filter->set_clear_button_enabled(true);
filter->add_theme_constant_override("minimum_character_width", 0);
filter->connect(SceneStringName(text_changed), callable_mp(this, &SceneTreeDialog::_filter_changed));
filter->connect(SceneStringName(gui_input), callable_mp(this, &SceneTreeDialog::_on_filter_gui_input));
register_text_enter(filter);
filter_hbc->add_child(filter);
// Add 'Show All' button to HBoxContainer next to the filter, visible only when valid_types is defined.