Re: Transition from [NSEvent phase] to [NSEvent momentumPhase]
Re: Transition from [NSEvent phase] to [NSEvent momentumPhase]
- Subject: Re: Transition from [NSEvent phase] to [NSEvent momentumPhase]
- From: Markus Spoettl <email@hidden>
- Date: Sat, 17 Mar 2012 08:48:54 +0100
On 17.03.12 02:21, Raleigh Ledet wrote:
The "System" doesn't know if momentum scroll events will follow
normal scroll event phrase or not. There is no way for the underlying
driver to inform the system of this. Sorry. I have to deal with this
problem inside appkit as well. It gets even more difficult because
the last phase:NSEventPhaseEnded scrollWheel event always has a delta
of 0 (though, don't every rely on that.). So you can't make an easy
velocity determination. (not that it would work because the user can
disable momentum scrolls)
If the trackpad is going to issue momentum scrollWheel events, it
will do so very quickly following the phase:NSEventPhaseEnded. The
momentumPhase: NSEventPhaseBegan event is probably already on the
event que (but it might not be). I'd scan the event que with a
nextEventMatchingMask:NSScrollWheelMask: momentumEvent = [NSApp
nextEventMatchingMask:NSScrollWheelMask untilDate[NSDate
dateWithTimeIntervalSinceNow:1.0/60.0]
inMode:@"mymomentumsearchmode"]; if (momentumEvent) { // got one }
else { // no momentum }
Thanks! This appears to be working in my case, meaning that it the
system does schedule momentum phase events by the time (phase ==
NSEventPhaseEnded) comes along. So I now only have to schedule delayed
cleanup if (phase == NSEventPhaseEnded) and there's no momentum phase on
the queue.
Though, as I alluded to above, this does bring up an interesting UI
problem. How will your animation work if the user flicks on the
trackpad but has momentum scrolling turned off?
Since the snap-back - which comes after scrolling - is animated, it
actually looks alright. Not nearly as terrible as I imagined when I read
your question :)
Thanks for the tip!
Regards
Markus
--
__________________________________________
Markus Spoettl
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden