From b93f4fa8795ae3cf5b435ac651fe87b3bbadddc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liru=20F=C3=A6rs?= Date: Sun, 18 Aug 2019 17:08:00 -0400 Subject: [PATCH] Do hitItem opted like drawItems, and be able to click on item slivers --- indra/llui/llscrolllistctrl.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index cea715fa9..ec8589a92 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -1912,14 +1912,16 @@ LLScrollListItem* LLScrollListCtrl::hitItem( S32 x, S32 y ) // allow for partial line at bottom S32 num_page_lines = getLinesPerPage(); + S32 list_size = mItemList.size() - 1; + S32 last_line = llmin(list_size, mScrollLines + num_page_lines); - S32 line = 0; - for(LLScrollListItem* item : mItemList) + for (S32 index = mScrollLines, line = mScrollLines; index <= list_size; ++index) { + LLScrollListItem* item = mItemList[index]; if (item->getFiltered()) continue; - if( mScrollLines <= line && line < mScrollLines + num_page_lines ) + { - if( item->getEnabled() && item_rect.pointInRect( x, y ) ) + if (item->getEnabled() && item_rect.pointInRect( x, y )) { hit_item = item; break; @@ -1927,7 +1929,7 @@ LLScrollListItem* LLScrollListCtrl::hitItem( S32 x, S32 y ) item_rect.translate(0, -mLineHeight); } - ++line; + if (++line > last_line) break; // Don't try to hit any undrawn items } return hit_item;