How does impulse / inertial scrolling work with Magic Mouse on NSScrollView?

When you scroll the new Apple Magic Mouse (at least 10.6, I cannot confirm the previous Mac OS), you get inertial scrolling, for example, scrolling on the iPhone (i.e. after scrolling your finger to scroll). does not stop abruptly, but gradually slows down). This behavior is “free” with all NSScrollViews, it will appear.

There are exceptional cases, such as Tweetie for Mac (I heard that Tweetie was written using the special Table View class, which is similar to how it UITableViewworks on the iPhone).

My question is, how does the scroll view know how to do this inertial scroll? I assume that the mouse [driver] repeatedly sends scroll events with decreasing scroll force (or something like that) during the scroll period. But I'm not sure how this works.

I am having scrolling problems in my scrollview class, and I'm trying to figure out why (obviously, we don't have the source code for Tweetie to understand why it doesn't get the correct scroll), but just trying to better understand how it works to fix my own problems.

+3
source share
3 answers

NSScrollView Magic Mouse. .

NSResponder -scrollWheel: NSLog, , Magic Mouse .

deltaX deltaY, .

( ) deviceDeltaX deviceDeltaY .

, Magic Mouse scrollPhase, , .

, deviceDeltaX deviceDeltaY NSEvent.

+7

, @ "NO" Key @ "AppleMomentumScrollSupported" (. Notes Magic Mouse Developer Notes). , Tweetie, .

 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
 NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:@"NO" forKey:@"AppleMomentumScrollSupported"];
 [defaults registerDefaults:appDefaults];
+1

The source code for TUIScrollView is available here https://github.com/twitter/twui

0
source

Source: https://habr.com/ru/post/1724771/


All Articles