GestureHandler[expr,{"gesture1"fun1,"gesture2"fun2,…}]
displays as expr, evaluating funi[value,velocity] whenever "gesturei" occurs within the screen space occupied by expr.
GestureHandler[expr,{"gesture"{fun,funend},…}]
evaluates fun as updates are received for "gesture", followed by funend[value,velocity] when the gesture ends.
GestureHandler[expr,{"gesture"{funstart,fun,funend},…}]
also evaluates fstart[value,velocity] when "gesture" begins.
GestureHandler
GestureHandler[expr,{"gesture1"fun1,"gesture2"fun2,…}]
displays as expr, evaluating funi[value,velocity] whenever "gesturei" occurs within the screen space occupied by expr.
GestureHandler[expr,{"gesture"{fun,funend},…}]
evaluates fun as updates are received for "gesture", followed by funend[value,velocity] when the gesture ends.
GestureHandler[expr,{"gesture"{funstart,fun,funend},…}]
also evaluates fstart[value,velocity] when "gesture" begins.
Details
- 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 funi. The first argument represents the magnitude of the gesture, while the second represents the velocity of the gesture.
-
"Pinch" value scale 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.
Examples
open all close allBasic Examples (2)
Print when a pinch gesture happens:
GestureHandler[Graphics[{}, Background -> Gray], "Pinch" :> Print["Pinched!"]]Dynamically print the distance of the last drag gesture:
DynamicModule[{drag = {0, 0}},
Row[{GestureHandler[Graphics[{}, Background -> Gray], "Drag" :> ((drag = #)&)], Dynamic[drag]}]]Scope (6)
Types of Gestures (5)
DynamicModule[{pos = {0, 0}}, Graphics[{GestureHandler[Disk[Dynamic[pos]], "Drag" :> (pos += #&)]}, PlotRange -> {{-5, 5}, {-5, 5}}]]DynamicModule[{scale = 1.}, GestureHandler[Graphics[{Circle[]}, Axes -> True, PlotRange -> Dynamic[scale * {-1, 1}]], "Pinch" :> (scale *= #&)]]DynamicModule[{col = RGBColor[Table[RandomReal[], {3}]]}, Graphics[GestureHandler[{Dynamic[col], Disk[]}, "Tap" :> (col = RGBColor[Table[RandomReal[], {3}]]&)]]]DynamicModule[{th = 0}, GestureHandler[Graphics[{Circle[], Disk[{0, 0}, 1, Dynamic[{th, th + Pi / 4}]]}], "Spin" :> (th += #&)]]DynamicModule[{col = RGBColor[Table[RandomReal[], {3}]]}, Graphics[GestureHandler[{Dynamic[col], Disk[]}, "LongPress" :> (col = RGBColor[Table[RandomReal[], {3}]]&)]]]See Also
Related Guides
History
Text
Wolfram Research (2012), GestureHandler, Wolfram Language function, https://reference.wolfram.com/language/ref/GestureHandler.html.
CMS
Wolfram Language. 2012. "GestureHandler." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/GestureHandler.html.
APA
Wolfram Language. (2012). GestureHandler. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GestureHandler.html
BibTeX
@misc{reference.wolfram_2026_gesturehandler, author="Wolfram Research", title="{GestureHandler}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/GestureHandler.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_gesturehandler, organization={Wolfram Research}, title={GestureHandler}, year={2012}, url={https://reference.wolfram.com/language/ref/GestureHandler.html}, note=[Accessed: 12-June-2026]}