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

Use defined key mapping for closing popups and dialogs

As opposed to hardcoding the escape key. Also removed such hardcoding in a few other places as well as a hardcoded enter key in one of the affected input fields.
This commit is contained in:
Arman Elgudzhyan
2023-05-20 17:26:13 -07:00
parent 809a982162
commit 8ab2cf3d2d
7 changed files with 26 additions and 66 deletions

View File

@@ -2698,22 +2698,10 @@ void FindBar::unhandled_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
if (k->is_pressed() && (rich_text_label->has_focus() || is_ancestor_of(get_viewport()->gui_get_focus_owner()))) {
bool accepted = true;
switch (k->get_keycode()) {
case Key::ESCAPE: {
_hide_bar();
} break;
default: {
accepted = false;
} break;
}
if (accepted) {
accept_event();
}
if (k.is_valid() && k->is_action_pressed(SNAME("ui_cancel"), false, true)) {
if (rich_text_label->has_focus() || is_ancestor_of(get_viewport()->gui_get_focus_owner())) {
_hide_bar();
accept_event();
}
}
}