wxVScrolledWindow on macOS requires 10 mouse wheel scrolls to begin scrolling (Issue #22139)

63 views
Skip to first unread message

Tobias Taschner

unread,
Feb 18, 2022, 8:53:35 AM2/18/22
to wx-...@googlegroups.com, Subscribed

Describe the bug
wxVScrolledWindow and descendants like wxVListBox do not respond to a single mouse wheel movement on macOS.
You need to scroll 10 times or more for the first movement to happen.

I've tracked down the issue to wxVarScrollHelperBase::HandleOnMouseWheel in vscroll.cpp:801

But I think the underlying problem is the handling of native mouse wheel events on macOS in window.mm:750.
On Windows the wheelRotation is always a multiple of the wheelDelta which is always 120 (hard coded in Windows SDK WHEEL_DELTA). On macOS at least without hasPreciseScrollingDeltas this is not the case and the logic in wxVarScrollHelperBase::HandleOnMouseWheel doesn't work correctly. But I would assume user code might also fail.
See below for my proposed fix.

To Reproduce
Steps to reproduce the behaviour, please make them as detailed as possible, e.g.

  1. Start the vscroll sample on macOS
  2. Move the mouse wheel down
  3. No scrolling happens
  4. Move 9 more times
  5. Window is scrolling

Potential Fix
My proposed fix is to make the rotation a multiple of the delta like on windows.
I'm not sure if it would be better to change the handling in wxVarScrollHelperBase::HandleOnMouseWheel.

diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm
index be92a9b632..99d2a2030f 100644
--- a/src/osx/cocoa/window.mm
+++ b/src/osx/cocoa/window.mm
@@ -747,8 +747,16 @@ void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEve
             }
             else
             {
-                deltaX = [nsEvent scrollingDeltaX] * 10;
-                deltaY = [nsEvent scrollingDeltaY] * 10;
+                deltaX = [nsEvent scrollingDeltaX];
+				if (deltaX > 0)
+					deltaX = 10;
+				else if (deltaX < 0)
+					deltaX = -10;
+                deltaY = [nsEvent scrollingDeltaY];
+				if (deltaY > 0)
+					deltaY = 10;
+				else if (deltaY < 0)
+					deltaY = -10;
             }
             
             wxevent.m_wheelDelta = 10;

Platform and version information

  • wxWidgets version you use: 3.1.6
  • wxWidgets port you use: wxOSX
  • OS and its version: 12.1


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22139@github.com>

Reply all
Reply to author
Forward
0 new messages