Skip to content

Commit

Permalink
Merge pull request #83065 from KoBeWi/tree_works_in_mysterious_ways
Browse files Browse the repository at this point in the history
Allow clicking buttons of non-selectable TreeItems
  • Loading branch information
akien-mga committed Oct 10, 2023
2 parents 53c6c38 + 7fb0cf2 commit 6f8b7e9
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions scene/gui/tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Texture2D> b = p_item->cells[col].buttons[j].texture;
Expand Down Expand Up @@ -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 */

Expand Down

0 comments on commit 6f8b7e9

Please sign in to comment.