Merge pull request #108706 from KoBeWi/excellent_code_quality

Fix inconsistent column in Tree click detection
This commit is contained in:
Thaddeus Crews
2025-07-18 11:05:07 -05:00

View File

@ -6037,13 +6037,22 @@ TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_
}
for (int i = 0; i < columns.size(); i++) {
int w = get_column_width(i);
if (pos.x < w) {
r_column = i;
int col_width = get_column_width(i);
if (p_item->cells[i].expand_right) {
int plus = 1;
while (i + plus < columns.size() && !p_item->cells[i + plus].editable && p_item->cells[i + plus].mode == TreeItem::CELL_MODE_STRING && p_item->cells[i + plus].text.is_empty() && p_item->cells[i + plus].icon.is_null() && p_item->cells[i + plus].buttons.is_empty()) {
col_width += theme_cache.h_separation;
col_width += get_column_width(i + plus);
plus++;
}
}
if (pos.x < col_width) {
r_column = i;
return p_item;
}
pos.x -= w;
pos.x -= col_width;
}
return nullptr;