diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 99635a25319..fe9f8b71252 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -2304,27 +2304,20 @@ VBoxContainer *ThemeTypeEditor::_create_item_list(Theme::DataType p_data_type) { } void ThemeTypeEditor::_update_type_list() { - ERR_FAIL_COND(edited_theme.is_null()); - - if (updating) { - return; - } - updating = true; - Control *focused = get_viewport()->gui_get_focus_owner(); + bool is_internal = focused == this; if (focused) { if (focusables.has(focused)) { // If focus is currently on one of the internal property editors, don't update. - updating = false; return; } Node *focus_parent = focused->get_parent(); while (focus_parent) { Control *c = Object::cast_to(focus_parent); + is_internal |= c == this; if (c && focusables.has(c)) { // If focus is currently on one of the internal property editors, don't update. - updating = false; return; } @@ -2332,6 +2325,21 @@ void ThemeTypeEditor::_update_type_list() { } } + if (is_internal) { + _update_type_list_internal(); + } else { + _update_type_list_debounced(); + } +} + +void ThemeTypeEditor::_update_type_list_internal() { + ERR_FAIL_COND(edited_theme.is_null()); + + if (updating) { + return; + } + updating = true; + List theme_types; edited_theme->get_type_list(&theme_types); theme_types.sort_custom(); @@ -3382,12 +3390,12 @@ void ThemeTypeEditor::_bind_methods() { void ThemeTypeEditor::set_edited_theme(const Ref &p_theme) { if (edited_theme.is_valid()) { - edited_theme->disconnect_changed(callable_mp(this, &ThemeTypeEditor::_update_type_list_debounced)); + edited_theme->disconnect_changed(callable_mp(this, &ThemeTypeEditor::_update_type_list)); } edited_theme = p_theme; if (edited_theme.is_valid()) { - edited_theme->connect_changed(callable_mp(this, &ThemeTypeEditor::_update_type_list_debounced)); + edited_theme->connect_changed(callable_mp(this, &ThemeTypeEditor::_update_type_list)); _update_type_list(); } @@ -3526,7 +3534,7 @@ ThemeTypeEditor::ThemeTypeEditor() { update_debounce_timer = memnew(Timer); update_debounce_timer->set_one_shot(true); update_debounce_timer->set_wait_time(0.5); - update_debounce_timer->connect("timeout", callable_mp(this, &ThemeTypeEditor::_update_type_list)); + update_debounce_timer->connect("timeout", callable_mp(this, &ThemeTypeEditor::_update_type_list_internal)); add_child(update_debounce_timer); } diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h index ba8e3a30b7a..adc92ede975 100644 --- a/editor/plugins/theme_editor_plugin.h +++ b/editor/plugins/theme_editor_plugin.h @@ -372,6 +372,7 @@ class ThemeTypeEditor : public MarginContainer { VBoxContainer *_create_item_list(Theme::DataType p_data_type); void _update_type_list(); + void _update_type_list_internal(); void _update_type_list_debounced(); HashMap _get_type_items(String p_type_name, Theme::DataType p_type, bool p_include_default); HBoxContainer *_create_property_control(Theme::DataType p_data_type, String p_item_name, bool p_editable);