Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions rendercanvas/wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,17 +458,24 @@ def _mouse_event(self, event_type: str, event: wx.MouseEvent, touches: bool = Tr
)

if event_type == "wheel":
delta = event.GetWheelDelta()
axis = event.GetWheelAxis()
rotation = event.GetWheelRotation()

# This is a little magic... it aims to match the scroll speed the Qt
# backend in a cross-platform way... It looks like just using the
# rotation produces a similar scroll experience, except it's rather
# slow/sluggish on MacOS for some reason, so we use a multiplier to
# correct that. Note that the non-linear scrolling on MacOS means
# that the exact gain does not even matter so much ...
gain = 2 if sys.platform == "darwin" else 1

dx = 0
dy = 0

if axis == wx.MOUSE_WHEEL_HORIZONTAL:
dx = delta * rotation
dx = gain * rotation
elif axis == wx.MOUSE_WHEEL_VERTICAL:
dy = delta * rotation
dy = gain * rotation

ev.update({"dx": -dx, "dy": -dy})

Expand Down
Loading