From ef8ec59f2f681440f3aaa6ec69bbaaa1e01164b5 Mon Sep 17 00:00:00 2001 From: kobewi Date: Sun, 7 Feb 2021 22:11:27 +0100 Subject: [PATCH] Set selected Tree item to null when deselected Co-authored-by: Brody Eller --- scene/gui/tree.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 0049b54f504..744e4e8832a 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -3322,6 +3322,14 @@ void Tree::item_selected(int p_column, TreeItem *p_item) { } void Tree::item_deselected(int p_column, TreeItem *p_item) { + if (selected_item == p_item) { + selected_item = nullptr; + } + + if (selected_col == p_column) { + selected_col = -1; + } + if (select_mode == SELECT_MULTI || select_mode == SELECT_SINGLE) { p_item->cells.write[p_column].selected = false; }