Skip to content

Commit 603ecc3

Browse files
Fix not valid selection index when the user clicks between the last item and the ListBox end
1 parent 3c39251 commit 603ecc3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/SFGUI/ListBox.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ ListBox::IndexType ListBox::GetItemAt( float y ) const {
414414
else if( item_index > m_max_displayed_items_count )
415415
return NONE;
416416
else
417-
return item_index - 1 + m_first_displayed_item;
417+
return std::min(item_index - 1 + m_first_displayed_item, GetItemsCount() - 1);
418418
}
419419

420420
bool ListBox::IsScrollbarVisible() const {

0 commit comments

Comments
 (0)