Skip to content

Commit 30c5729

Browse files
committed
Fix UI focus being shown when it shouldn't
1 parent 0fdbf05 commit 30c5729

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

editor/docks/groups_editor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ void GroupsEditor::_confirm_add() {
515515
undo_redo->add_undo_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree");
516516

517517
undo_redo->commit_action();
518-
tree->grab_focus();
518+
tree->grab_focus(true);
519519
}
520520

521521
void GroupsEditor::_confirm_rename() {
@@ -566,7 +566,7 @@ void GroupsEditor::_confirm_rename() {
566566

567567
undo_redo->commit_action();
568568

569-
tree->grab_focus();
569+
tree->grab_focus(true);
570570
}
571571

572572
void GroupsEditor::_confirm_delete() {
@@ -606,7 +606,7 @@ void GroupsEditor::_confirm_delete() {
606606
undo_redo->add_undo_method(this, "_update_tree");
607607

608608
undo_redo->commit_action();
609-
tree->grab_focus();
609+
tree->grab_focus(true);
610610
}
611611

612612
void GroupsEditor::_show_add_group_dialog() {

editor/gui/editor_spin_slider.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ void EditorSpinSlider::_value_input_gui_input(const Ref<InputEvent> &p_event) {
275275
case Key::ESCAPE: {
276276
value_input_closed_frame = Engine::get_singleton()->get_frames_drawn();
277277
if (value_input_popup) {
278+
value_input_focus_visible = value_input->has_focus(true);
278279
value_input_popup->hide();
279280
}
280281
} break;
@@ -610,6 +611,7 @@ void EditorSpinSlider::_evaluate_input_text() {
610611
void EditorSpinSlider::_value_input_submitted(const String &p_text) {
611612
value_input_closed_frame = Engine::get_singleton()->get_frames_drawn();
612613
if (value_input_popup) {
614+
value_input_focus_visible = value_input->has_focus(true);
613615
value_input_popup->hide();
614616
}
615617
}
@@ -644,9 +646,10 @@ void EditorSpinSlider::_value_focus_exited() {
644646
value_input_popup->hide();
645647
}
646648
} else {
647-
// Enter or Esc was pressed.
648-
grab_focus();
649+
// Enter or Esc was pressed. Keep showing the focus if already present.
650+
grab_focus(!value_input_focus_visible);
649651
}
652+
value_input_focus_visible = false;
650653

651654
emit_signal("value_focus_exited");
652655
}

editor/gui/editor_spin_slider.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class EditorSpinSlider : public Range {
6767
LineEdit *value_input = nullptr;
6868
uint64_t value_input_closed_frame = 0;
6969
bool value_input_dirty = false;
70+
bool value_input_focus_visible = false;
7071

7172
public:
7273
enum ControlState {

scene/main/viewport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ bool Viewport::_can_hide_focus_state() {
552552
}
553553

554554
void Viewport::_on_settings_changed() {
555-
if (!gui.hide_focus && _can_hide_focus_state()) {
555+
if (!gui.hide_focus || _can_hide_focus_state()) {
556556
return;
557557
}
558558

0 commit comments

Comments
 (0)