From 01b8beb023eb7a4c9f1027afc7ea47d13ff2fcbd Mon Sep 17 00:00:00 2001 From: Bruno Ortiz Date: Tue, 20 Dec 2016 19:47:24 -0200 Subject: [PATCH] Making deselect work for TreeItem when select_mode is SELECT_SINGLE and item_selected is now properly emitted (cherry picked from commit 4b9a96859b6d80b9b50a0512d3ab9c6d05a4deb1) --- scene/gui/tree.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 0e63c1188cb..7158ffb3e53 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1379,11 +1379,7 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c if (select_mode==SELECT_ROW) { - - if (p_selected==p_current) { - - if (!c.selected) { - + if (p_selected==p_current && !c.selected) { c.selected=true; selected_item=p_selected; selected_col=0; @@ -1393,24 +1389,17 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c emitted_row=true; } //if (p_col==i) - // p_current->selected_signal.call(p_col); - } + // p_current->selected_signal.call(p_col); - } else { - - if (c.selected) { + } else if (c.selected) { c.selected=false; //p_current->deselected_signal.call(p_col); - } - } - } else if (select_mode==SELECT_SINGLE || select_mode==SELECT_MULTI) { if (!r_in_range && &selected_cell==&c) { - if (!selected_cell.selected) { selected_cell.selected=true; @@ -1421,6 +1410,8 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c emit_signal("cell_selected"); if (select_mode==SELECT_MULTI) emit_signal("multi_selected",p_current,i,true); + else if(select_mode == SELECT_SINGLE) + emit_signal("item_selected"); } else if (select_mode==SELECT_MULTI && (selected_item!=p_selected || selected_col!=i)) { @@ -2909,8 +2900,7 @@ void Tree::item_selected(int p_column,TreeItem *p_item) { void Tree::item_deselected(int p_column,TreeItem *p_item) { - if (select_mode==SELECT_MULTI) { - + if (select_mode==SELECT_MULTI || select_mode == SELECT_SINGLE) { p_item->cells[p_column].selected=false; } update();