Skip to content

Commit

Permalink
Merge pull request godotengine#81128 from KoBeWi/devourer_of_input_me…
Browse files Browse the repository at this point in the history
…ets_destroyer_of_focus

Unfocus LineEdit when pressing Escape
  • Loading branch information
akien-mga committed Aug 30, 2023
2 parents d222194 + e21c30e commit f7c48cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scene/gui/line_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions scene/gui/spin_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down

0 comments on commit f7c48cf

Please sign in to comment.