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: Raleigh Ledet <email@hidden>
- Date: Fri, 16 Mar 2012 18:21:43 -0700
Sorry to be late to this party. I've been busy. ;)
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
}
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?
-raleigh
On Mar 11, 2012, at 12:43 PM, Markus Spoettl <email@hidden> wrote:
> Hello,
>
> in a custom view I'm processing -scrollWheel: events for smooth scrolling using the trackpad.
>
> When the user flicks across the trackpad, scrolling events first go through a phase cycle delivered through [NSEvent phase] (NSEventPhaseBegan -> NSEventPhaseChanged -> NSEventPhaseEnded).
>
> After that (depending on how the flick ended physically), the system may deliver additional scrolling events with [NSEvent momentumPhase] set (NSEventPhaseBegan -> NSEventPhaseChanged -> NSEventPhaseEnded).
>
> A typical sequence of events looks like:
>
> phase: NSEventPhaseBegan / momentumPhase: NSEventPhaseNone
> phase: NSEventPhaseChanged / momentumPhase: NSEventPhaseNone
> [...]
> phase: NSEventPhaseChanged / momentumPhase: NSEventPhaseNone
> phase: NSEventPhaseEnded / momentumPhase: NSEventPhaseNone
> phase: NSEventPhaseNone / momentumPhase: NSEventPhaseBegan
> phase: NSEventPhaseNone / momentumPhase: NSEventPhaseChanged
> [...]
> phase: NSEventPhaseNone / momentumPhase: NSEventPhaseChanged
> phase: NSEventPhaseNone / momentumPhase: NSEventPhaseEnded
>
>
> The trouble is that there seems no way of knowing that there will be momentumPhase events following a "normal" phase cycle. I need to do cleanup but I must be sure scrolling is over before doing it.
>
> The system knows (at the time of sending the final normal -phase event) that it's going to send additional -momentumPhase events. Is there a way to find out?
>
> 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
_______________________________________________
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