Browse Source

Fix ItemList click detection gaps

David Giardi 1 year ago
parent
commit
c892fd8691
1 changed files with 7 additions and 0 deletions
  1. 7 0
      scene/gui/item_list.cpp

+ 7 - 0
scene/gui/item_list.cpp

@@ -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.
 		}