Merge pull request #83065 from KoBeWi/tree_works_in_mysterious_ways

Allow clicking buttons of non-selectable TreeItems
This commit is contained in:
Rémi Verschelde 2023-10-10 12:34:22 +02:00
commit 6f8b7e9895
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 13 additions and 13 deletions

View File

@ -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;
@ -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 */