GestureHandler

GestureHandler[expr,{"gesture1"fun1,"gesture2"fun2,]
displays as expr, evaluating whenever occurs within the screen space occupied by expr.

GestureHandler[expr,{"gesture"{fun,funend},}]
evaluates fun as updates are received for , followed by when the gesture ends.

GestureHandler[expr,{"gesture"{funstart,fun,funend},}]
also evaluates when begins.

DetailsDetails

  • GestureHandler is only active on touchscreen devices. Otherwise, it acts as an inert wrapper.
  • Functions take arguments that are associated with the specific gesture. Typically, the argument is a value in scaled coordinates that represents the magnitude of the gesture.
  • Standard gestures include:
  • "Pinch"two-fingered gesture where the fingers pinch together or apart; typically used for resizing
    "Drag"one-fingered dragging gesture
    {"Drag",n}dragging gesture using touches
  • GestureHandler passes two arguments to . The first argument represents the magnitude of the gesture, while the second represents the velocity of the gesture.
  • "Pinch"valuescale of the pinch as a fraction of the starting distance between the touches
    "Drag"{valx,valy}drag distance as a fraction of the horizontal and vertical sizes of expr
  • When GestureHandler expressions are nested, events are by default shared by all the expressions, with the innermost expression operating first on a particular event.

ExamplesExamplesopen allclose all

Basic Examples  (2)Basic Examples  (2)

Print when a pinch gesture happens:

In[1]:=
Click for copyable input

Dynamically print the distance of the last drag gesture:

In[1]:=
Click for copyable input
Introduced in 2012
(9.0)