summaryrefslogtreecommitdiff
path: root/vcl/source/control/listbox.cxx
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2023-12-08 11:50:40 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2023-12-12 06:22:11 +0100
commit22250df05830700b2555348b8ac46ee1007d0e5d (patch)
tree82b684fa884b5311bac4f67dc398816774c2d2c1 /vcl/source/control/listbox.cxx
parent946a7fd8063219b3621fbdc22c28a57ee72a2067 (diff)
tdf#158548 vcl: Require mouse over listbox to mouse-wheel through entries
As described in tdf#158548, it's unexpected that listbox/ combobox entries change when using the mouse wheel while the listbox/combobox has keyboard focus, but the mouse cursor is positioned somewhere else Therefore, only do that for the VCL ListBox when the mouse cursor is currently positioned above it, which also matches what e.g. native Qt applications do. (When using the gtk3 VCL plugin that uses a native GtkComboBox, nothing changes on scroll independent of the position.) Change-Id: I8a69628471c1cd4258194627b95145d6b8fb686a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160459 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/source/control/listbox.cxx')
-rw-r--r--vcl/source/control/listbox.cxx12
1 files changed, 7 insertions, 5 deletions
diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx
index 7e87ae390185..e189c8480f05 100644
--- a/vcl/source/control/listbox.cxx
+++ b/vcl/source/control/listbox.cxx
@@ -867,12 +867,14 @@ bool ListBox::PreNotify( NotifyEvent& rNEvt )
(rNEvt.GetCommandEvent()->GetCommand() == CommandEventId::Wheel) &&
(rNEvt.GetWindow() == mpImplWin) )
{
+ const Point& rMousePos = rNEvt.GetCommandEvent()->GetMousePosPixel();
+ const tools::Rectangle aWinRect(mpImplWin->GetPosPixel(), mpImplWin->GetSizePixel());
+ const bool bMousePositionedOverWin = aWinRect.Contains(rMousePos);
+
MouseWheelBehaviour nWheelBehavior( GetSettings().GetMouseSettings().GetWheelBehavior() );
- if ( ( nWheelBehavior == MouseWheelBehaviour::ALWAYS )
- || ( ( nWheelBehavior == MouseWheelBehaviour::FocusOnly )
- && HasChildPathFocus()
- )
- )
+ if (bMousePositionedOverWin
+ && ((nWheelBehavior == MouseWheelBehaviour::ALWAYS)
+ || ((nWheelBehavior == MouseWheelBehaviour::FocusOnly) && HasChildPathFocus())))
{
bDone = mpImplLB->HandleWheelAsCursorTravel(*rNEvt.GetCommandEvent(), *this);
}