Class PointerGestureEvent
One step of a touchpad gesture, from a device or from pointer:gesture, passed to pointer_gesture handlers. A gesture is a "begin", any number of "update"s, and an "end", all of the same kind.
Pinching to zoom with Super held:
local zoom = 1
local zoom_at_start
wm.input:on("pointer_gesture", function(event)
if event.kind ~= "pinch" or not event.modifiers.super then return end
event:prevent_default()
if event.phase == "begin" then
zoom_at_start = zoom
elseif event.phase == "update" and zoom_at_start then
zoom = zoom_at_start * event.scale
else
zoom_at_start = nil
end
end)Properties
event.pointer: Pointerpointer read only
The pointer whose device made the gesture.
event.kind: "swipe" | "pinch" | "hold"kind read only
A swipe moves the fingers together. A pinch spreads or closes them and can turn them. A hold is fingers resting without moving.
event.phase: "begin" | "update" | "end"phase read only
Which step this is.
- A hold has no updates.
event.fingers: numberfingers read only
How many fingers. Updates and the end carry the begin's count.
event.delta: Pointdelta read only
How far the fingers' centre moved since the last step.
- 0,0 on a begin, an end and a hold.
event.scale: numberscale read only
For a pinch update, the finger spread relative to the begin: 2 is twice as far apart, 0.5 half.
- 1 on other steps and kinds.
event.rotation: numberrotation read only
For a pinch update, degrees the fingers turned clockwise since the last step.
- 0 on other steps and kinds.
event.cancelled: booleancancelled read only
On an end, whether the gesture was called off rather than finished, for example because a finger was added or lifted part way.
- False on other steps.
event.modifiers: Modifiersmodifiers read only
The modifiers on the keyboard of the pointer's seat.
- All false when the seat has no keyboard.
Methods
event:prevent_default() -> nilprevent_default
On a begin, keeps the whole gesture from the app: the begin, its updates and its end.
- Does nothing on an update or an end.