Fix UI focus being shown when it shouldn't

This commit is contained in:
Michael Alexsander 2025-10-07 12:05:34 -03:00
parent 06faefc9f4
commit e32b9274a3
No known key found for this signature in database
GPG key ID: A9C91EE110F4EABA
7 changed files with 39 additions and 16 deletions

View file

@ -277,6 +277,7 @@ void EditorSpinSlider::_value_input_gui_input(const Ref<InputEvent> &p_event) {
case Key::ESCAPE: {
value_input_closed_frame = Engine::get_singleton()->get_frames_drawn();
if (value_input_popup) {
value_input_focus_visible = value_input->has_focus(true);
value_input_popup->hide();
}
} break;
@ -612,6 +613,7 @@ void EditorSpinSlider::_evaluate_input_text() {
void EditorSpinSlider::_value_input_submitted(const String &p_text) {
value_input_closed_frame = Engine::get_singleton()->get_frames_drawn();
if (value_input_popup) {
value_input_focus_visible = value_input->has_focus(true);
value_input_popup->hide();
}
}
@ -646,9 +648,10 @@ void EditorSpinSlider::_value_focus_exited() {
value_input_popup->hide();
}
} else {
// Enter or Esc was pressed.
grab_focus();
// Enter or Esc was pressed. Keep showing the focus if already present.
grab_focus(!value_input_focus_visible);
}
value_input_focus_visible = false;
emit_signal("value_focus_exited");
}

View file

@ -67,6 +67,7 @@ class EditorSpinSlider : public Range {
LineEdit *value_input = nullptr;
uint64_t value_input_closed_frame = 0;
bool value_input_dirty = false;
bool value_input_focus_visible = false;
public:
enum ControlState {