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:
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -313,7 +302,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() {
|
||||
@ -329,6 +318,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user