Protocol

Gesture

An instance that matches a sequence of events to a gesture, and returns a stream of values for each of its states.

Declaration

protocol Gesture

Overview

Create custom gestures by declaring types that conform to the Gesture protocol.

Topics

Implementing a Custom Gesture

var body: Self.Body

The content and behavior of the gesture.

Required.

associatedtype Body

The type of gesture representing the body of Self.

Required.

Performing the Gesture

func onChanged((Self.Value) -> Void) -> _ChangedGesture<Self>

Adds an action to perform when the gesture’s value changes.

func onEnded((Self.Value) -> Void) -> _EndedGesture<Self>

Adds an action to perform when the gesture ends.

associatedtype Value

The type representing the gesture’s value.

Required.

Composing Gestures

func simultaneously<Other>(with: Other) -> SimultaneousGesture<Self, Other>

Combines a gesture with another gesture to create a new gesture that recognizes both gestures at the same time.

func sequenced<Other>(before: Other) -> SequenceGesture<Self, Other>

Sequences a gesture with another one to create a new gesture, which results in the second gesture only receiving events after the first gesture succeeds.

func exclusively<Other>(before: Other) -> ExclusiveGesture<Self, Other>

Combines two gestures exclusively to create a new gesture where only one gesture succeeds, giving precedence to the first gesture.

Adding Modifier Keys to a Gesture

func modifiers(EventModifiers) -> _ModifiersGesture<Self>

Combines a gesture with keyboard modifiers.

struct EventModifiers

A set of key modifiers that you can add to a gesture.

Transforming a Gesture

func map<T>((Self.Value) -> T) -> _MapGesture<Self, T>

Returns a gesture that’s the result of mapping the given closure over the gesture.

Relationships

Conforming Types

See Also

Custom Gestures

struct AnyGesture

A type-erased gesture.