Merge pull request #88347 from davthedev/itemlist-click-gap-fix

Fix ItemList click detection gaps
This commit is contained in:
Rémi Verschelde 2024-02-15 17:35:54 +01:00
commit d48c450c62
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -1495,6 +1495,13 @@ int ItemList::get_item_at_position(const Point2 &p_pos, bool p_exact) const {
for (int i = 0; i < items.size(); i++) { for (int i = 0; i < items.size(); i++) {
Rect2 rc = items[i].rect_cache; Rect2 rc = items[i].rect_cache;
// Grow the detection rectangle to match the grown selection indicator.
rc.position.y -= theme_cache.v_separation / 2;
rc.size.y += theme_cache.v_separation;
rc.position.x -= theme_cache.h_separation / 2;
rc.size.x += theme_cache.h_separation;
if (i % current_columns == current_columns - 1) { if (i % current_columns == current_columns - 1) {
rc.size.width = get_size().width - rc.position.x; // Make sure you can still select the last item when clicking past the column. rc.size.width = get_size().width - rc.position.x; // Make sure you can still select the last item when clicking past the column.
} }