Fix ItemList click detection gaps

This commit is contained in:
David Giardi 2024-02-15 00:15:35 +01:00
parent 907db8eebc
commit c892fd8691

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++) {
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) {
rc.size.width = get_size().width - rc.position.x; // Make sure you can still select the last item when clicking past the column.
}