Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions editor/docks/groups_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ void GroupsEditor::_confirm_add() {
undo_redo->add_undo_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree");

undo_redo->commit_action();
tree->grab_focus();
tree->grab_focus(true);
}

void GroupsEditor::_confirm_rename() {
Expand Down Expand Up @@ -566,7 +566,7 @@ void GroupsEditor::_confirm_rename() {

undo_redo->commit_action();

tree->grab_focus();
tree->grab_focus(true);
}

void GroupsEditor::_confirm_delete() {
Expand Down Expand Up @@ -606,7 +606,7 @@ void GroupsEditor::_confirm_delete() {
undo_redo->add_undo_method(this, "_update_tree");

undo_redo->commit_action();
tree->grab_focus();
tree->grab_focus(true);
}

void GroupsEditor::_show_add_group_dialog() {
Expand Down
7 changes: 5 additions & 2 deletions editor/gui/editor_spin_slider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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");
}
Expand Down
1 change: 1 addition & 0 deletions editor/gui/editor_spin_slider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 15 additions & 0 deletions editor/settings/action_map_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,13 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info
actions_cache = p_action_infos;
}

Pair<String, int> selected_item;
TreeItem *ti = action_tree->get_selected();
if (ti) {
selected_item.first = ti->get_text(0);
selected_item.second = action_tree->get_selected_column();
}

HashSet<String> collapsed_actions;
TreeItem *root = action_tree->get_root();
if (root) {
Expand Down Expand Up @@ -496,6 +503,10 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info
action_item->set_custom_bg_color(0, get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor)));
action_item->set_custom_bg_color(1, get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor)));

if (selected_item.first == action_info.name) {
action_item->select(selected_item.second);
}

for (int evnt_idx = 0; evnt_idx < events.size(); evnt_idx++) {
Ref<InputEvent> event = events[evnt_idx];
if (event.is_null()) {
Expand Down Expand Up @@ -544,6 +555,10 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info
event_item->add_button(2, get_editor_theme_icon(SNAME("Remove")), BUTTON_REMOVE_EVENT, false, TTRC("Remove Event"), TTRC("Remove Event"));
event_item->set_button_color(2, 0, Color(1, 1, 1, 0.75));
event_item->set_button_color(2, 1, Color(1, 1, 1, 0.75));

if (selected_item.first == event_item->get_text(0)) {
event_item->select(selected_item.second);
}
}
}
}
Expand Down
20 changes: 13 additions & 7 deletions scene/gui/tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3285,9 +3285,6 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int
click_handled = true;
popup_pressing_edited_item = p_item;
popup_pressing_edited_item_column = col;

pressing_item_rect = Rect2(get_global_position() + Point2i(col_ofs, _get_title_button_height() + y_ofs) - theme_cache.offset, Size2(col_width, item_h));
pressing_for_editor_text = editor_text;
pressing_for_editor = true;

return -1; // Select.
Expand Down Expand Up @@ -3361,14 +3358,15 @@ void Tree::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
if (p_event->is_action_pressed("ui_text_newline_blank", true)) {
accept_event();
} else if (p_event->is_action_pressed("ui_text_newline")) {
bool hide_focus = !text_editor->has_focus(true);
popup_edit_committed = true; // End edit popup processing.
popup_editor->hide();
_apply_multiline_edit();
_apply_multiline_edit(hide_focus);
accept_event();
}
}

void Tree::_apply_multiline_edit() {
void Tree::_apply_multiline_edit(bool p_hide_focus) {
if (!popup_edited_item) {
return;
}
Expand All @@ -3387,6 +3385,7 @@ void Tree::_apply_multiline_edit() {
}
}

grab_focus(p_hide_focus);
item_edited(popup_edited_item_col, popup_edited_item);
queue_redraw();
}
Expand All @@ -3400,6 +3399,8 @@ void Tree::_line_editor_submit(String p_text) {
return; // ESC pressed, app focus lost, or forced close from code.
}

bool hide_focus = !line_editor->has_focus(true);

popup_edit_committed = true; // End edit popup processing.
popup_editor->hide();

Expand Down Expand Up @@ -3432,6 +3433,7 @@ void Tree::_line_editor_submit(String p_text) {
}
}

grab_focus(hide_focus);
item_edited(popup_edited_item_col, popup_edited_item);
queue_redraw();
}
Expand Down Expand Up @@ -4404,6 +4406,8 @@ bool Tree::edit_selected(bool p_force_edit) {
}
popup_rect.position += get_screen_position();

bool hide_focus = !has_focus(true);

line_editor->clear();
line_editor->set_text(c.mode == TreeItem::CELL_MODE_STRING ? c.text : String::num(c.val, Math::range_step_decimals(c.step)));
line_editor->select_all();
Expand All @@ -4420,10 +4424,12 @@ bool Tree::edit_selected(bool p_force_edit) {
popup_editor->popup();
popup_editor->child_controls_changed();

line_editor->grab_focus();
line_editor->grab_focus(hide_focus);

return true;
} else if (c.mode == TreeItem::CELL_MODE_STRING && c.edit_multiline) {
bool hide_focus = !has_focus(true);

line_editor->hide();

text_editor->clear();
Expand All @@ -4440,7 +4446,7 @@ bool Tree::edit_selected(bool p_force_edit) {
popup_editor->popup();
popup_editor->child_controls_changed();

text_editor->grab_focus();
text_editor->grab_focus(hide_focus);

return true;
}
Expand Down
4 changes: 1 addition & 3 deletions scene/gui/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,7 @@ class Tree : public Control {

int pressed_button = -1;
bool pressing_for_editor = false;
String pressing_for_editor_text;
Vector2 pressing_pos;
Rect2 pressing_item_rect;

Vector2 hovered_pos;
bool is_mouse_hovering = false;
Expand Down Expand Up @@ -562,7 +560,7 @@ class Tree : public Control {
void select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev = nullptr, bool *r_in_range = nullptr, bool p_force_deselect = false);
int propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int x_limit, bool p_double_click, TreeItem *p_item, MouseButton p_button, const Ref<InputEventWithModifiers> &p_mod);
void _line_editor_submit(String p_text);
void _apply_multiline_edit();
void _apply_multiline_edit(bool p_hide_focus = false);
void _text_editor_popup_modal_close();
void _text_editor_gui_input(const Ref<InputEvent> &p_event);
void value_editor_changed(double p_value);
Expand Down
2 changes: 1 addition & 1 deletion scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ bool Viewport::_can_hide_focus_state() {
}

void Viewport::_on_settings_changed() {
if (!gui.hide_focus && _can_hide_focus_state()) {
if (!gui.hide_focus || _can_hide_focus_state()) {
return;
}

Expand Down