onTapGesture
Adds an action to perform when this view recognizes a tap gesture, and provides the action with the location of the interaction.
View ModifieriOS 27.0+macOS 27.0+tvOS 27.0+watchOS 27.0+visionOS 27.0+
Overloads
3 ways to call compose().onTapGesture(). Each is one SwiftUI overload, picked by the arguments you pass.
compose().onTapGesture({
count?: number,
coordinateSpace?: SwiftUI.CoordinateSpaceProtocol,
inputKinds?: SwiftUI.GestureInputKinds,
perform: (arg0: CGPoint) => void,
})nonisolated func onTapGesture(
count: Int = 1,
coordinateSpace: some CoordinateSpaceProtocol = .local,
inputKinds: GestureInputKinds = .all,
perform action: @escaping (CGPoint) -> Void
) -> some ViewParameters
options.countnumberThe number of taps or clicks required to trigger the action closure provided in
action.options.coordinateSpaceSwiftUI.CoordinateSpaceProtocolThe coordinate space in which to receive location values.
options.inputKindsSwiftUI.GestureInputKindsA 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*(arg0: CGPoint) => void
See also
More in Events and lifecycle.
- onAppearAdds an action to perform before this view appears.
- onChangeAdds a modifier for this view that fires an action when a specific value changes.
- onContinueUserActivityRegisters a handler to invoke in response to a user activity that your app receives.
- onContinuousHoverAdds an action to perform when the pointer enters, moves within, and exits the view's bounds.
- onDisappearAdds an action to perform after this view disappears.
- onDragActivates this view as the source of a drag and drop operation.
- onDragSessionUpdatedSpecifies an action to perform on each update of an ongoing dragging operation activated by draggable(:) or anther drag modifiers.
- onDropDefines the destination of a drag and drop operation that handles the dropped content with a closure that you specify.
- onDropSessionUpdatedSpecifies an action to perform on each update of an ongoing drop operation activated by dropDestination(:) or other drop modifiers.
- onGeometryChangeAdds an action to be performed when a value, created from a geometry proxy, changes.
- onHingeChangeAdds an action to perform when the hinge context of the view hierarchy changes.
- onHoverAdds an action to perform when the user moves the pointer over or away from the view's frame.