onLongPressGesture

Adds an action to perform when this view recognizes a long press gesture.

View ModifieriOS 27.0+macOS 27.0+watchOS 27.0+visionOS 27.0+

Overloads

2 ways to call compose().onLongPressGesture(). Each is one SwiftUI overload, picked by the arguments you pass.

React
compose().onLongPressGesture({
  minimumDuration?: number,
  maximumDistance?: number,
  inputKinds?: SwiftUI.GestureInputKinds,
  perform: () => void,
  onPressingChanged?: ((arg0: boolean) => void) | null,
})
Swift
nonisolated func onLongPressGesture(
    minimumDuration: Double = 0.5,
    maximumDistance: CGFloat = 10,
    inputKinds: GestureInputKinds = .all,
    perform action: @escaping () -> Void,
    onPressingChanged: ((Bool) -> Void)? = nil
) -> some View

Parameters

  • options.minimumDurationnumber

    The minimum duration of the long press that must elapse before the gesture succeeds.

  • options.maximumDistancenumber

    The maximum distance that the fingers or cursor performing the long press can move before the gesture fails.

  • options.inputKindsSwiftUI.GestureInputKinds

    A set of input kinds that this gesture recognizes. If not specified, the gesture will recognize all applicable input kinds that a person can use to perform it.

  • options.perform*() => void
  • options.onPressingChanged((arg0: boolean) => void) | null

    A closure to run when the pressing state of the gesture changes, passing the current state as a parameter.

See also

More in Events and lifecycle.