diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 9549941b2b1..91510bd825a 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -4221,6 +4221,8 @@ void Tree::gui_input(const Ref &p_event) { } void Tree::_determine_hovered_item() { + hovered_update_queued = false; + Ref bg = theme_cache.panel_style; bool rtl = is_layout_rtl(); @@ -4308,6 +4310,14 @@ void Tree::_determine_hovered_item() { } } +void Tree::_queue_update_hovered_item() { + if (hovered_update_queued) { + return; + } + hovered_update_queued = true; + callable_mp(this, &Tree::_determine_hovered_item).call_deferred(); +} + bool Tree::edit_selected(bool p_force_edit) { TreeItem *s = get_selected(); ERR_FAIL_NULL_V_MSG(s, false, "No item selected."); @@ -5128,9 +5138,7 @@ TreeItem *Tree::create_item(TreeItem *p_parent, int p_index) { ti = create_item(root, p_index); } } - - _determine_hovered_item(); - + _queue_update_hovered_item(); queue_accessibility_update(); return ti; } diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 63b73386987..94a65fdc10b 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -737,7 +737,9 @@ private: bool enable_auto_tooltip = true; + bool hovered_update_queued = false; void _determine_hovered_item(); + void _queue_update_hovered_item(); int _count_selected_items(TreeItem *p_from) const; bool _is_branch_selected(TreeItem *p_from) const;