summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-12-21 19:25:41 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2024-12-21 20:48:54 +0100
commit6eb53d3ecc839d5988a581132c81bfdf9ee2fa69 (patch)
tree893d031ba2452e5cc97b2f8ab7fe77177c4ef0be
parent938a5ce4c5ddc149362f800e33cb8913913a2616 (diff)
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 <m.weghorn@posteo.de> 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 <m.weghorn@posteo.de>
-rw-r--r--vcl/source/control/spinfld.cxx8
1 files changed, 2 insertions, 6 deletions
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