summaryrefslogtreecommitdiff
path: root/vcl/source/control
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-05-13 16:37:45 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2024-05-14 07:25:44 +0200
commit869b88488ac443cc64943254064da20b0f361c56 (patch)
tree759633fa9e844b729e5fcfd494001ae66238e018 /vcl/source/control
parent1201d3d6b0457bac30105bf5371c76a4ef69f29a (diff)
tdf#160824 vcl: Require mouse over spinfield to mouse-wheel through values
In the same way that commit 22250df05830700b2555348b8ac46ee1007d0e5d Author: Michael Weghorn <m.weghorn@posteo.de> Date: Fri Dec 8 11:50:40 2023 +0100 tdf#158548 vcl: Require mouse over listbox to mouse-wheel through entries restricted changing listbox values for the focused listbox on mouse-wheel to the case when the listbox is also hovered over by the mouse, do the same for `SpinField` as well, to avoid accidently changing the value as described e.g. for the tdf#160824 scenario. This is also in line with Qt spin boxes that only change their values on mouse-wheel when the mouse pointer is above them. For the gtk3 VCL plugin that uses native spin boxes, this commit has no effect, and the value doesn't change on mouse-wheel at all. Change-Id: I22277294f76655cd13b1dc57416c82afe44460d1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167604 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
Diffstat (limited to 'vcl/source/control')
-rw-r--r--vcl/source/control/spinfld.cxx13
1 files changed, 11 insertions, 2 deletions
diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx
index 973825a3a977..1eb8357a2940 100644
--- a/vcl/source/control/spinfld.cxx
+++ b/vcl/source/control/spinfld.cxx
@@ -543,9 +543,18 @@ bool SpinField::EventNotify(NotifyEvent& rNEvt)
{
if ((rNEvt.GetCommandEvent()->GetCommand() == CommandEventId::Wheel) && !IsReadOnly())
{
+ const Point& rMousePos = rNEvt.GetCommandEvent()->GetMousePosPixel();
+ bool bMouseHovered = maUpperRect.Contains(rMousePos) || maLowerRect.Contains(rMousePos);
+ if (!bMouseHovered && mpEdit)
+ {
+ const tools::Rectangle aEditRect(mpEdit->GetPosPixel(), mpEdit->GetSizePixel());
+ bMouseHovered = aEditRect.Contains(rMousePos);
+ }
+
MouseWheelBehaviour nWheelBehavior(GetSettings().GetMouseSettings().GetWheelBehavior());
- if (nWheelBehavior == MouseWheelBehaviour::ALWAYS
- || (nWheelBehavior == MouseWheelBehaviour::FocusOnly && HasChildPathFocus()))
+ if (bMouseHovered
+ && (nWheelBehavior == MouseWheelBehaviour::ALWAYS
+ || (nWheelBehavior == MouseWheelBehaviour::FocusOnly && HasChildPathFocus())))
{
const CommandWheelData* pData = rNEvt.GetCommandEvent()->GetWheelData();
if (pData->GetMode() == CommandWheelMode::SCROLL)