diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-08-30 08:47:26 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-08-30 08:47:26 +0200 |
commit | f7c48cf8039d07f113d38cf9115547a75ea1d3c9 (patch) | |
tree | 31e7214b9ef485d49f590266085579a456bf8951 | |
parent | d222194d0db5c78290a186da4f2bce6d39999e59 (diff) | |
parent | e21c30ec11ed6ac90cc0a2a915879a850922a43e (diff) | |
download | redot-engine-f7c48cf8039d07f113d38cf9115547a75ea1d3c9.tar.gz |
Merge pull request #81128 from KoBeWi/devourer_of_input_meets_destroyer_of_focus
Unfocus LineEdit when pressing Escape
-rw-r--r-- | scene/gui/line_edit.cpp | 5 | ||||
-rw-r--r-- | scene/gui/spin_box.cpp | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index bb727ff62c..4c1e591bd7 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -482,6 +482,11 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) { return; } + if (k->is_action("ui_cancel")) { + release_focus(); + return; + } + if (is_shortcut_keys_enabled()) { if (k->is_action("ui_copy", true)) { copy_text(); diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 7cb54f24ea..4af694ae3d 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -210,6 +210,11 @@ void SpinBox::_line_edit_focus_exit() { if (line_edit->is_menu_visible()) { return; } + // Discontinue because the focus_exit was caused by canceling. + if (Input::get_singleton()->is_action_pressed("ui_cancel")) { + _update_text(); + return; + } _text_submitted(line_edit->get_text()); } |