]> git.saurik.com Git - wxWidgets.git/commitdiff
[ 1515520 ] wxOwnerDrawnComboBox mouse hover on partially visible item.
authorWłodzimierz Skiba <abx@abx.art.pl>
Mon, 3 Jul 2006 12:23:51 +0000 (12:23 +0000)
committerWłodzimierz Skiba <abx@abx.art.pl>
Mon, 3 Jul 2006 12:23:51 +0000 (12:23 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39946 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/odcombo.cpp

index 5aa99fefa8f224e5bff5c5dd554b09b6f5375226..969d674f1d3a4a4d7b679cf2baf1e832445d152d 100644 (file)
@@ -301,12 +301,30 @@ void wxVListBoxComboPopup::OnPopup()
 
 void wxVListBoxComboPopup::OnMouseMove(wxMouseEvent& event)
 {
+    event.Skip();
+
     // Move selection to cursor if it is inside the popup
-    int itemHere = GetItemAtPosition(event.GetPosition());
-    if ( itemHere >= 0 )
-        wxVListBox::SetSelection(itemHere);
 
-    event.Skip();
+    int y = event.GetPosition().y;
+    int fromBottom = GetClientSize().y - y;
+
+    // Since in any case we need to find out if the last item is only
+    // partially visible, we might just as well replicate the HitTest
+    // loop here.
+    const size_t lineMax = GetVisibleEnd();
+    for ( size_t line = GetVisibleBegin(); line < lineMax; line++ )
+    {
+        y -= OnGetLineHeight(line);
+        if ( y < 0 )
+        {
+            // Only change selection if item is fully visible
+            if ( (y + fromBottom) >= 0 )
+            {
+                wxVListBox::SetSelection((int)line);
+                return;
+            }
+        }
+    }
 }
 
 void wxVListBoxComboPopup::OnLeftClick(wxMouseEvent& WXUNUSED(event))