Skip to content

Commit 1f9dc89

Browse files
committed
Merge pull request #108706 from KoBeWi/excellent_code_quality
Fix inconsistent column in Tree click detection
2 parents f92f1ce + 1f4044c commit 1f9dc89

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

scene/gui/tree.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6037,13 +6037,22 @@ TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_
60376037
}
60386038

60396039
for (int i = 0; i < columns.size(); i++) {
6040-
int w = get_column_width(i);
6041-
if (pos.x < w) {
6042-
r_column = i;
6040+
int col_width = get_column_width(i);
6041+
6042+
if (p_item->cells[i].expand_right) {
6043+
int plus = 1;
6044+
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()) {
6045+
col_width += theme_cache.h_separation;
6046+
col_width += get_column_width(i + plus);
6047+
plus++;
6048+
}
6049+
}
60436050

6051+
if (pos.x < col_width) {
6052+
r_column = i;
60446053
return p_item;
60456054
}
6046-
pos.x -= w;
6055+
pos.x -= col_width;
60476056
}
60486057

60496058
return nullptr;

0 commit comments

Comments
 (0)