Skip to main content

GestureDetector

How to implement a custom GestureDetector

The ControlTouchSession supports GestureDetectors. You simply register your own detector and register it at the ControlTouchSession.

  • The ClickGestureDetector is one of the existing detectors. It detects click, drag and press related gestures.
  • Since it only detects the gestures it is clear that the ControlTouchSession is the only place where it is referenced (and also only because it is registered by default).
  • GestureDetector::OnEvent is the only interaction interface with the ControlTouchSession.

The ControlTouchSession will send these events to the gesture detector:

UpdateEvent

This event indicates an update iteration (one per frame)

GestureDetector::TouchInput

This is a single/multi touch event extended by this information:

  1. The state of the gesture detector session (FirstDown, LastUp).
  2. The behavior that has currently the touch focus (which is the touchable behavior that was hit by the first finger that touched the screen during a gesture detector session)
  3. The behavior that is currently touched by the touch event (also updated by Drag).

The following states of the gesture detector session are available:

  • FirstDown: The gesture detector session begins when the first finger touches the screen.
  • LastUp: The gesture detector session ends when the last finger is removed from the screen.

In between you will get updates in the following cases:

  • Down: another finger touched the screen
  • Drag: a finger has been moved.
  • Up: one finger has been removed from the screen. But at least one more is on the screen.

GestureDetector::AbortEvent

This event tells that another behavior has taken the exclusive touch control. Hence, no gesture detector will participate in the current gesture detector session and therefore has to reset all internal states and wait for the next session.

GestureDetector::DeregisterEvent

The provided behavior is removed from the ControlTouchSession. Hence the gesture detector also has to remove all references to that behavior.

See also: