From 6eb53d3ecc839d5988a581132c81bfdf9ee2fa69 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Sat, 21 Dec 2024 19:25:41 +0100 Subject: tdf#164233 vcl: Fix and simplify spin field mouse over check Instead of checking individually whether the mouse pos is over the SpinField's up or down button or the `mpEdit`, just check the SpinField's whole rectangle. The mouse event pos is relative to the SpinField, so use (0, 0) for the top left position of the SpinField's rect used in the check. This is not only simpler, but also fixes the case of the UNO control when the "Spin Button" options is disabled in which case there are no buttons and `mpEdit` is null, so `bMouseHovered` would always be false and adjusting the spin field value for that control using the mouse wheel wouldn't even work when mouse-hovered after the initial check was introduced in commit 869b88488ac443cc64943254064da20b0f361c56 Author: Michael Weghorn Date: Mon May 13 16:37:45 2024 +0200 tdf#160824 vcl: Require mouse over spinfield to mouse-wheel through values Change-Id: I3a2ee3af8af872e4a330a4d5e9f5cd6a2de89754 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179085 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- vcl/source/control/spinfld.cxx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'vcl/source') diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx index 1eb8357a2940..2bdbdad66c75 100644 --- a/vcl/source/control/spinfld.cxx +++ b/vcl/source/control/spinfld.cxx @@ -543,13 +543,9 @@ bool SpinField::EventNotify(NotifyEvent& rNEvt) { if ((rNEvt.GetCommandEvent()->GetCommand() == CommandEventId::Wheel) && !IsReadOnly()) { + const tools::Rectangle aRect(Point(0, 0), GetSizePixel()); 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); - } + const bool bMouseHovered = aRect.Contains(rMousePos); MouseWheelBehaviour nWheelBehavior(GetSettings().GetMouseSettings().GetWheelBehavior()); if (bMouseHovered -- cgit