How does the momentum/inertial scroll work with the Magic Mouse on NSScrollView?

Posted by jbrennan on Stack Overflow See other posts from Stack Overflow or by jbrennan
Published on 2009-12-04T19:06:16Z Indexed on 2010/05/04 9:08 UTC
Read the original article Hit count: 364

When you scroll with the newer Apple Magic Mouse (at least on 10.6, I can't confirm any previous Mac OS) you get inertial scroll like scrolling on iPhone (that is, after a flick of the finger to scroll, it doesn't abruptly stop, but instead gradually slows down). This behaviour is "for free" with all NSScrollViews, it would appear.

There are exceptional cases, such as Tweetie for Mac (I've heard Tweetie was written with a custom Table View class that works akin to how UITableView works on iPhone).

My question is, how do the scroll views know how to do this inertial scrolling? My guess is the mouse [driver] repeatedly sends scroll events with a dampening scroll magnitude (or something like that) over the scroll period. But I'm not really sure how it works.

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

© Stack Overflow or respective owner

Related posts about magic-mouse

Related posts about nsscrollview