From 276ebe79a6bc76ed5aa5d85f7d4b56f945babd94 Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Mon, 3 Jul 2006 12:23:51 +0000 Subject: [PATCH] [ 1515520 ] wxOwnerDrawnComboBox mouse hover on partially visible item. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39946 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/odcombo.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/generic/odcombo.cpp b/src/generic/odcombo.cpp index 5aa99fefa8..969d674f1d 100644 --- a/src/generic/odcombo.cpp +++ b/src/generic/odcombo.cpp @@ -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)) -- 2.45.2