summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2023-01-12 14:13:49 +0100
committerJuan Linietsky <reduzio@gmail.com>2023-01-12 14:13:49 +0100
commit2543aec5e4ce1b6018b6b7ecfd862290ec5462f8 (patch)
treec819b231c2c1b094ce9e8bd59f13ff7277d78877
parentcaf94f244e1a952300c6426f5d7d9939dd93d472 (diff)
Fix TAB key usage in EditorSpinSlider (and hence inpector).
* This ensures that the tab key usage is correct in all situations in EditorSpinSlider * The ESC key can also close the lineedit popup. I can't find a proper issue to fix, but partially solves the concerns raised in #37723.
-rw-r--r--editor/editor_spin_slider.cpp17
-rw-r--r--editor/editor_spin_slider.h2
2 files changed, 13 insertions, 6 deletions
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index ea03b1c744..177266e366 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -253,6 +253,12 @@ void EditorSpinSlider::_value_input_gui_input(const Ref<InputEvent> &p_event) {
value_input_dirty = true;
set_process_internal(true);
} break;
+ case Key::ESCAPE: {
+ value_input_closed_frame = Engine::get_singleton()->get_frames_drawn();
+ if (value_input_popup) {
+ value_input_popup->hide();
+ }
+ } break;
default:
break;
}
@@ -479,10 +485,10 @@ void EditorSpinSlider::_notification(int p_what) {
} break;
case NOTIFICATION_FOCUS_ENTER: {
- if ((Input::get_singleton()->is_action_pressed("ui_focus_next") || Input::get_singleton()->is_action_pressed("ui_focus_prev")) && !value_input_just_closed) {
+ if ((Input::get_singleton()->is_action_pressed("ui_focus_next") || Input::get_singleton()->is_action_pressed("ui_focus_prev")) && value_input_closed_frame != Engine::get_singleton()->get_frames_drawn()) {
_focus_entered();
}
- value_input_just_closed = false;
+ value_input_closed_frame = 0;
} break;
}
}
@@ -553,7 +559,7 @@ void EditorSpinSlider::_evaluate_input_text() {
//text_submitted signal
void EditorSpinSlider::_value_input_submitted(const String &p_text) {
- value_input_just_closed = true;
+ value_input_closed_frame = Engine::get_singleton()->get_frames_drawn();
if (value_input_popup) {
value_input_popup->hide();
}
@@ -562,7 +568,7 @@ void EditorSpinSlider::_value_input_submitted(const String &p_text) {
//modal_closed signal
void EditorSpinSlider::_value_input_closed() {
_evaluate_input_text();
- value_input_just_closed = true;
+ value_input_closed_frame = Engine::get_singleton()->get_frames_drawn();
}
//focus_exited signal
@@ -578,7 +584,7 @@ void EditorSpinSlider::_value_focus_exited() {
// -> TAB was pressed
// -> modal_close was not called
// -> need to close/hide manually
- if (!value_input_just_closed) { //value_input_just_closed should do the same
+ if (value_input_closed_frame != Engine::get_singleton()->get_frames_drawn()) {
if (value_input_popup) {
value_input_popup->hide();
}
@@ -672,6 +678,7 @@ void EditorSpinSlider::_ensure_input_popup() {
add_child(value_input_popup);
value_input = memnew(LineEdit);
+ value_input->set_focus_mode(FOCUS_CLICK);
value_input_popup->add_child(value_input);
value_input->set_anchors_and_offsets_preset(PRESET_FULL_RECT);
value_input_popup->connect("hidden", callable_mp(this, &EditorSpinSlider::_value_input_closed));
diff --git a/editor/editor_spin_slider.h b/editor/editor_spin_slider.h
index 99eb953166..a4d810b18b 100644
--- a/editor/editor_spin_slider.h
+++ b/editor/editor_spin_slider.h
@@ -65,7 +65,7 @@ class EditorSpinSlider : public Range {
Control *value_input_popup = nullptr;
LineEdit *value_input = nullptr;
- bool value_input_just_closed = false;
+ uint64_t value_input_closed_frame = 0;
bool value_input_dirty = false;
bool hide_slider = false;