Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mouse wheel zooming in both directions on Mac #1678

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fedulvtubudul
Copy link

This PR fixes #804

Here is original zoom wheel handler code:

def wheel(self, event):
    self.zoomCanvas(event.x, event.y, pow(ZOOM,(event.delta//120)))

event.delta equals -1 (scroll up) or 1 (scroll down) on my setup (MacOS 12.2.1, Logitech MX 3 mouse, medium scrolling speed in system settings, "natural" scroll direction). In Python 2 rounding goes away from zero, so event.delta//120 gives either 1 or -1, which is OK. But running in Python 3.9, event.delta//120 results -1 or 0. That why only one zooming direction works.

I propose a fix that seems compatible both with Python 2 and 3 and should not break or change scrolling behavior.

@Harvie
Copy link
Collaborator

Harvie commented Feb 20, 2022

Thank you for this fix. I hope few other users can test this and share their experience with fix as well.
If i remember correctly, i've merged similar thing some time ago and it ended up breaking zoom for some of the users (while fixing it for others). So i will test it myself on ArchLinux/X11 and hopefully we can get feedback from users on other platforms as well.

Copy link
Contributor

@rschell rschell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't having issues on my Pi implementation, zoom function continue to work both locally and in a remote VNC session.

@Harvie
Copy link
Collaborator

Harvie commented Apr 10, 2023

Ok thanks, can you please resolve the conflicts, so we can merge?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zooming Viewport with the mousewheel only works in one direction
3 participants