Skip to content

Scrollwheel/trackpad scrolling for MacOS #5012

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

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

Conversation

RCCoop
Copy link

@RCCoop RCCoop commented Feb 22, 2023

Goals ⚽

Allow for scrolling around the chart on MacOS using two-finger trackpad scrolling, which is a more natural interaction than having to click and drag.

Implementation Details 🚧

Being new to this library, I may not be doing this the most elegant way, but I added override func scrollWheel(with:) to BarLineChartViewBase, and wrapped it with #if os(macOS). To implement the scrollWheel function, I mostly copied panGestureRecognized(_:), removing options that seemed specific to GestureRecognizer implementations, and replacing the translation and velocity calculations with NSEvent versions. The end result is that you can pan around in the view using two-finger trackpad scrolling.

Testing Details 🔍

I tested by using the ChartsDemo-macOS app in both BarDemoViewController and LineDemoViewController, each with and without dragDecelerationEnabled, to zoom and scroll. It was very simple testing, but it seemed to work.

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.

1 participant