diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index e78789edbd7..2d3166270ba 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -2770,21 +2770,9 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int x -= theme_cache.h_separation; } - if (!p_item->disable_folding && !hide_folding && !p_item->cells[col].editable && !p_item->cells[col].selectable && p_item->get_first_child()) { - if (enable_recursive_folding && p_mod->is_shift_pressed()) { - p_item->set_collapsed_recursive(!p_item->is_collapsed()); - } else { - p_item->set_collapsed(!p_item->is_collapsed()); - } - return -1; //collapse/uncollapse because nothing can be done with item - } - const TreeItem::Cell &c = p_item->cells[col]; - bool already_selected = c.selected; - bool already_cursor = (p_item == selected_item) && col == selected_col; - - if (!cache.rtl && p_item->cells[col].buttons.size()) { + if (!cache.rtl && !p_item->cells[col].buttons.is_empty()) { int button_w = 0; for (int j = p_item->cells[col].buttons.size() - 1; j >= 0; j--) { Ref b = p_item->cells[col].buttons[j].texture; @@ -2827,6 +2815,18 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int col_width -= w + theme_cache.button_margin; } + if (!p_item->disable_folding && !hide_folding && !p_item->cells[col].editable && !p_item->cells[col].selectable && p_item->get_first_child()) { + if (enable_recursive_folding && p_mod->is_shift_pressed()) { + p_item->set_collapsed_recursive(!p_item->is_collapsed()); + } else { + p_item->set_collapsed(!p_item->is_collapsed()); + } + return -1; // Collapse/uncollapse, because nothing can be done with the item. + } + + bool already_selected = c.selected; + bool already_cursor = (p_item == selected_item) && col == selected_col; + if (p_button == MouseButton::LEFT || (p_button == MouseButton::RIGHT && allow_rmb_select)) { /* process selection */