diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 3faaeae01e1..da73fbfeb7f 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -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;