Gesture Recognizer States (Compact 2013)
3/26/2014
In the course of recognizing a gesture, the recognizer takes on three possible states, defined in GestureRecognizer.hpp and shown in the following table. The state of the recognizer determines how the GestureRecognizer object will behave when it receives a touch event.
Recognizer state |
Description |
---|---|
WaitingForPrimary |
The initial state before a gesture session starts. The GestureRecognizer constructor sets the state to this value when it creates an object. When GestureRecognizer::RecognizeGesture receives a touch event while in this state, it calls GestureRecognizer::CheckSessionStart, which examines the touch event for an initial primary contact point. If it finds one, it changes the state to TrackingPrimary or WaitingForAllUp. It changes the state to TrackingPrimary if the TOUCHEVENTF_PRIMARY flag is set for the first contact down point; that is, the first point in the point array that has the TOUCHEVENTF_DOWN flag set. Otherwise, it changes the state to WaitingForAllUp if the TOUCHEVENTF_SYMMETRIC flag is set for that point. The gesture session starts when the state changes from WaitingForPrimary to one of the other states. When this occurs, GestureRecognizer::RecognizeGesture calls GestureRecognizer::BeginSession which, in turn, calls the OnBeginGestureSession method for the active recognizer, either DMRecognizer or TouchGesture. |
TrackingPrimary |
The state in which the recognizer tries to recognize gestures. In this state, GestureRecognizer passes touch events to the active recognizer; either DMRecognizer or TouchGesture. It also examines the touch events to detect end of contact for the primary contact point. When this occurs, it changes the state to WaitingForAllUp. |
WaitingForAllUp |
The state in which contact has ended for the primary contact point but not for all contact points. In this state, GestureRecognizer::RecognizeGesture waits for contact to end for all contact points. When this occurs, it calls GestureRecognizer::EndSession, which, in turn, calls the OnEndGestureSession method for the active recognizer, either DMRecognizer or TouchGesture. |