diff options
author | kobewi <kobewi4e@gmail.com> | 2023-08-22 16:29:00 +0200 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2023-08-29 14:53:49 +0200 |
commit | e21c30ec11ed6ac90cc0a2a915879a850922a43e (patch) | |
tree | 2dc3b832c59e8cfd19728c3950028e8c35bde24f | |
parent | 247c3548d810136ffe9c1694cd76db3236efaa90 (diff) | |
download | redot-engine-e21c30ec11ed6ac90cc0a2a915879a850922a43e.tar.gz |
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()); } |