Gesture Handler
You can set the gestures that are bound to a component. You can use the UIGestureEvent object to add or remove gestures.
NOTE
The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version.
GestureHandler<T>
Represents the base type for gesture handlers.
tag
tag(tag: string): T
Sets the tag for the gesture handler.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| tag | string | Yes | Gesture handler tag. |
Return values
| Type | Description |
|---|---|
| T | Current component. |
allowedTypes14+
allowedTypes(types: Array<SourceTool>): T
Sets the event input sources supported by the gesture handler.
Atomic service API: This API can be used in atomic services since API version 14.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| types | Array<SourceTool> | Yes | Supported input source types. |
Return values
| Type | Description |
|---|---|
| T | Current component. |
BaseHandlerOptions15+
Provides the parameters of the basic gesture handler.
Atomic service API: This API can be used in atomic services since API version 15.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| isFingerCountLimited | boolean | No | Yes | Whether to enforce the exact number of fingers touching the screen. true: Enforce the exact number of fingers touching the screen. false: Do not enforce the exact number of fingers touching the screen. Default value: false |
TapGestureHandler
Defines a type of gesture handler object for tap gestures.
constructor
constructor(options?: TapGestureHandlerOptions)
Constructor used to create a tap gesture handler instance.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| options | TapGestureHandlerOptions | No | Parameters of the tap gesture handler. |
onAction
onAction(event: Callback<GestureEvent>): TapGestureHandler
Sets the callback for successful tap gesture recognition.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<GestureEvent> | Yes | Callback invoked upon successful tap gesture recognition. |
Return values
| Type | Description |
|---|---|
| TapGestureHandler | Tap gesture handler object. |
TapGestureHandlerOptions
Provides the parameters of the tap gesture handler. Inherits from BaseHandlerOptions.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| count | number | No | Yes | Number of consecutive taps. If the value is less than 1 or is not set, the default value is used. Default value: 1 Value range: [0, +∞) NOTE 1. If multi-tap is configured, the timeout interval between a lift and the next tap is 300 ms. 2. If the distance between the last tapped position and the current tapped position exceeds 60 vp, gesture recognition fails. Atomic service API: This API can be used in atomic services since API version 12. |
| fingers | number | No | Yes | Number of fingers required to trigger a tap. The value ranges from 1 to 10. If the value is less than 1 or is not set, the default value is used. Default value: 1 NOTE 1. If the value is greater than 1, the tap gesture will fail to be recognized when the required number of fingers is not pressed within 300 milliseconds after the first finger touches down, or when the required number of fingers is not lifted within 300 milliseconds after the first finger is lifted. 2. When the number of fingers touching the screen exceeds the set value, the gesture can be recognized. Atomic service API: This API can be used in atomic services since API version 12. |
| isFingerCountLimited15+ | boolean | No | Yes | Whether to enforce the exact number of fingers touching the screen. true: Enforce the exact number of fingers touching the screen. false: Do not enforce the exact number of fingers touching the screen. With the value true, the gesture recognition fails if the number of fingers touching the screen does not match the configured value of fingers. In multi-tap events (where the count parameter is greater than 1), each tap must have the same number of fingers as the configured value; otherwise, the gesture recognition fails. Default value: false Atomic service API: This API can be used in atomic services since API version 15. |
| distanceThreshold23+ | number | No | Yes | Movement threshold for the tap gesture. If the value is less than or equal to 0 or is not set, the default value is used. Default value: 2^31-1 Unit: vp NOTE If the finger movement exceeds the preset movement threshold, the gesture recognition fails. If the default threshold is used during initialization and the finger moves beyond the component's touch target, the tap gesture recognition fails. Atomic service API: This API can be used in atomic services since API version 23. |
LongPressGestureHandler
Defines a long press gesture handler object.
constructor
constructor(options?: LongPressGestureHandlerOptions)
Constructor used to create a long press gesture handler instance.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| options | LongPressGestureHandlerOptions | No | Parameters of the long press gesture handler. |
onAction
onAction(event: Callback<GestureEvent>): LongPressGestureHandler
Sets the callback for successful long press gesture recognition.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<GestureEvent> | Yes | Callback invoked upon successful long press gesture recognition. |
Return values
| Type | Description |
|---|---|
| LongPressGestureHandler | Long press gesture handler object. |
onActionEnd
onActionEnd(event: Callback<GestureEvent>): LongPressGestureHandler
Sets the callback for long press gesture recognition completion. This callback is triggered when all fingers are lifted after successful recognition.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<GestureEvent> | Yes | Callback invoked when long press gesture recognition completes. |
Return values
| Type | Description |
|---|---|
| LongPressGestureHandler | Long press gesture handler object. |
onActionCancel
onActionCancel(event: Callback<void>): LongPressGestureHandler
Sets the callback for long press gesture cancellation. This callback is triggered when a touch cancellation event occurs after successful recognition. No gesture event information is returned.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<void> | Yes | Callback invoked when the long press gesture is cancelled. |
Return values
| Type | Description |
|---|---|
| LongPressGestureHandler | Long press gesture handler object. |
onActionCancel18+
onActionCancel(event: Callback<GestureEvent>): LongPressGestureHandler
Sets the callback for long press gesture cancellation. This callback is triggered when a touch cancellation event occurs after successful recognition. Compared with onActionCancel, this API returns gesture event information.
Atomic service API: This API can be used in atomic services since API version 18.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<GestureEvent> | Yes | Callback invoked when the long press gesture is cancelled. This callback returns gesture event information. |
Return values
| Type | Description |
|---|---|
| LongPressGestureHandler | Long press gesture handler object. |
LongPressGestureHandlerOptions
Provides the parameters of the long press gesture handler. Inherits from BaseHandlerOptions.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| fingers | number | No | Yes | Minimum number of fingers to trigger a long press gesture. The value ranges from 1 to 10. Default value: 1 Value range: [1, 10] NOTE If a finger moves more than 15 px after being pressed, the gesture recognition fails. Atomic service API: This API can be used in atomic services since API version 12. |
| repeat | boolean | No | Yes | Whether to continuously trigger the event callback. The value true means to continuously trigger the event callback, and false means the opposite. Default value: false Atomic service API: This API can be used in atomic services since API version 12. |
| duration | number | No | Yes | Minimum hold-down time, in ms. Default value: 500 NOTE Value range: [0, +∞). If the value is less than or equal to 0, the default value 500 is used. Atomic service API: This API can be used in atomic services since API version 12. |
| isFingerCountLimited15+ | boolean | No | Yes | Whether to enforce the exact number of fingers touching the screen. true: Enforce the exact number of fingers touching the screen. false: Do not enforce the exact number of fingers touching the screen. With the value true, the gesture recognition fails if the number of fingers touching the screen does not match the configured value of fingers. For gestures that have already been successfully recognized, changes in the number of fingers touching the screen will not trigger the repeat event. However, if the number of fingers touching the screen returns to the configured minimum number, the onAction event can be triggered. The onActionEnd event can also be triggered regardless of the finger count. Default value: false Atomic service API: This API can be used in atomic services since API version 15. |
| allowableMovement22+ | number | No | Yes | Maximum movement distance recognized by the long press gesture recognizer, in px. Default value: 15 Value range: (0, +∞). If the value is less than or equal to 0, the default value 15 is used. Atomic service API: This API can be used in atomic services since API version 22. |
PanGestureHandler
Defines a pan gesture handler object.
constructor
constructor(options?: PanGestureHandlerOptions)
Constructor used to create a pan gesture handler instance.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| options | PanGestureHandlerOptions | No | Parameters of the pan gesture handler. |
onActionStart
onActionStart(event: Callback<GestureEvent>): PanGestureHandler
Sets the callback for successful pan gesture recognition.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<GestureEvent> | Yes | Callback invoked upon successful pan gesture recognition. |
Return values
| Type | Description |
|---|---|
| PanGestureHandler | Pan gesture handler object. |
onActionUpdate
onActionUpdate(event: Callback<GestureEvent>): PanGestureHandler
Sets the callback for pan gesture movement updates. The callback is triggered when the pan gesture moves.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<GestureEvent> | Yes | Callback invoked during pan gesture movement. If fingerList contains multiple fingers, this callback updates the location information of only one finger each time. |
Return values
| Type | Description |
|---|---|
| PanGestureHandler | Pan gesture handler object. |
onActionEnd
onActionEnd(event: Callback<GestureEvent>): PanGestureHandler
Sets the callback for pan gesture recognition completion. This callback is triggered when all fingers are lifted after successful recognition.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<GestureEvent> | Yes | Callback invoked when pan gesture recognition completes. |
Return values
| Type | Description |
|---|---|
| PanGestureHandler | Pan gesture handler object. |
onActionCancel
onActionCancel(event: Callback<void>): PanGestureHandler
Sets the callback for pan gesture cancellation. This callback is triggered when a touch cancellation event occurs after successful recognition. No gesture event information is returned.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<void> | Yes | Callback invoked when the pan gesture is cancelled. |
Return values
| Type | Description |
|---|---|
| PanGestureHandler | Pan gesture handler object. |
onActionCancel18+
onActionCancel(event: Callback<GestureEvent>): PanGestureHandler
Sets the callback for pan gesture cancellation. This callback is triggered when a touch cancellation event occurs after successful recognition. Compared with onActionCancel, this API returns gesture event information.
Atomic service API: This API can be used in atomic services since API version 18.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<GestureEvent> | Yes | Callback invoked when the pan gesture is cancelled. Gesture event information is returned. |
Return values
| Type | Description |
|---|---|
| PanGestureHandler | Pan gesture handler object. |
PanGestureHandlerOptions
Provides the parameters of the pan gesture handler. Inherits from BaseHandlerOptions.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| fingers | number | No | Yes | Minimum number of fingers to trigger a pan gesture. The value ranges from 1 to 10. Default value: 1 Value range: [1, 10] NOTE If the value is less than 1 or is not set, the default value is used. Atomic service API: This API can be used in atomic services since API version 12. |
| direction | PanDirection | No | Yes | Pan direction. The value supports the AND (&) and OR (|) operations. Default value: PanDirection.All Atomic service API: This API can be used in atomic services since API version 12. |
| distance | number | No | Yes | Minimum pan distance to trigger the gesture, in vp. Default value: 8 for the stylus and 5 for other input sources NOTE If a pan gesture and a tab swipe occur at the same time, set distance to 1 to make the gesture more easily recognizable. Value range: [0, +∞). If the value specified is less than 0, the default value is used. Since API version 19, the default value is 8, in vp, for the stylus. Atomic service API: This API can be used in atomic services since API version 12. |
| distanceMap19+ | Map<SourceTool, number> | No | Yes | Minimum pan distance for different input sources to trigger the gesture, in vp. Default value: 8 for the stylus and 5 for other input sources Value range: [0, +∞). If the value specified is less than 0, the default value is used. Atomic service API: This API can be used in atomic services since API version 19. |
SwipeGestureHandler
Defines a swipe gesture handler object.
constructor
constructor(options?: SwipeGestureHandlerOptions)
Constructor used to create a swipe gesture handler instance.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| options | SwipeGestureHandlerOptions | No | Parameters of the swipe gesture handler. |
onAction
onAction(event: Callback<GestureEvent>): SwipeGestureHandler
Sets the callback for successful swipe gesture recognition.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<GestureEvent> | Yes | Callback invoked upon successful swipe gesture recognition. |
Return values
| Type | Description |
|---|---|
| SwipeGestureHandler | Swipe gesture handler object. |
SwipeGestureHandlerOptions
Provides the parameters of the swipe gesture handler. Inherits from BaseHandlerOptions.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| fingers | number | No | Yes | Minimum number of fingers to trigger a swipe gesture. The value ranges from 1 to 10. Default value: 1 Value range: [1, 10] |
| direction | SwipeDirection | No | Yes | Directions in which the swipe gesture can be recognized. Default value: SwipeDirection.All |
| speed | number | No | Yes | Minimum speed of the swipe gesture. Default value: 100 vp/s NOTE If the value is less than or equal to 0, it will be converted to the default value. |
| isFingerCountLimited15+ | boolean | No | Yes | Whether to enforce the exact number of fingers touching the screen. true: Enforce the exact number of fingers touching the screen. false: Do not enforce the exact number of fingers touching the screen. With the value true, the gesture recognition fails if the number of fingers touching the screen does not match the configured value of fingers. Default value: false Atomic service API: This API can be used in atomic services since API version 15. |
PinchGestureHandler
Defines a type of gesture handler object for pinch gestures.
constructor
constructor(options?: PinchGestureHandlerOptions)
Constructor used to create a pinch gesture handler instance.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| options | PinchGestureHandlerOptions | No | Parameters of the pinch gesture handler. |
onActionStart
onActionStart(event: Callback<GestureEvent>): PinchGestureHandler
Sets the callback for successful pinch gesture recognition.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<GestureEvent> | Yes | Callback invoked upon successful pinch gesture recognition. |
Return values
| Type | Description |
|---|---|
| PinchGestureHandler | Pinch gesture handler object. |
onActionUpdate
onActionUpdate(event: Callback<GestureEvent>): PinchGestureHandler
Sets the callback for pinch gesture movement updates. The callback is triggered when the pinch gesture moves.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<GestureEvent> | Yes | Callback invoked during pinch gesture movement. |
Return values
| Type | Description |
|---|---|
| PinchGestureHandler | Pinch gesture handler object. |
onActionEnd
onActionEnd(event: Callback<GestureEvent>): PinchGestureHandler
Sets the callback for pinch gesture recognition completion. This callback is triggered when all fingers are lifted after successful recognition.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<GestureEvent> | Yes | Callback invoked when pinch gesture recognition completes. |
Return values
| Type | Description |
|---|---|
| PinchGestureHandler | Pinch gesture handler object. |
onActionCancel
onActionCancel(event: Callback<void>): PinchGestureHandler
Sets the callback for pinch gesture cancellation. This callback is triggered when a touch cancellation event occurs after successful recognition. No gesture event information is returned.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<void> | Yes | Callback invoked when the pinch gesture is cancelled. No gesture event information is returned. |
Return values
| Type | Description |
|---|---|
| PinchGestureHandler | Pinch gesture handler object. |
onActionCancel18+
onActionCancel(event: Callback<GestureEvent>): PinchGestureHandler
Sets the callback for pinch gesture cancellation. This callback is triggered when a touch cancellation event occurs after successful recognition. Compared with onActionCancel, this API returns gesture event information.
Atomic service API: This API can be used in atomic services since API version 18.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<GestureEvent> | Yes | Callback invoked when the pinch gesture is cancelled. Gesture event information is returned. |
Return values
| Type | Description |
|---|---|
| PinchGestureHandler | Pinch gesture handler object. |
PinchGestureHandlerOptions
Provides the parameters of the pinch gesture handler. Inherits from BaseHandlerOptions.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| fingers | number | No | Yes | Minimum number of fingers required to trigger the pinch gesture. The value ranges from 2 to 5. Default value: 2 Value range: [2, 5] While more fingers than the minimum number can be pressed to trigger the gesture, only the first fingers of the minimum number participate in gesture calculation. |
| distance | number | No | Yes | Minimum recognition distance, in vp. Default value: 5 NOTE If the value is less than or equal to 0, it will be converted to the default value. |
| isFingerCountLimited15+ | boolean | No | Yes | Whether to enforce the exact number of fingers touching the screen. true: Enforce the exact number of fingers touching the screen. false: Do not enforce the exact number of fingers touching the screen. With the value true, the gesture recognition fails if the number of fingers touching the screen does not match the configured value of fingers. The gesture can only be successfully recognized if the number of fingers equals the configured minimum and the swipe distance meets the threshold. Note that only the first two fingers that touch the screen are considered for the gesture. If one of these fingers is lifted, the gesture recognition fails. For gestures that have already been successfully recognized, changing the number of fingers touching the screen will not trigger the onActionUpdate event, but the onActionEnd event can still be triggered. Default value: false Atomic service API: This API can be used in atomic services since API version 15. |
RotationGestureHandler
Defines a rotation gesture handler object.
constructor
constructor(options?: RotationGestureHandlerOptions)
Constructor used to create a rotation gesture handler instance.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| options | RotationGestureHandlerOptions | No | Parameters of the rotation gesture handler. |
onActionStart
onActionStart(event: Callback<GestureEvent>): RotationGestureHandler
Sets the callback for successful rotation gesture recognition.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<GestureEvent> | Yes | Callback invoked upon successful rotation gesture recognition. |
Return values
| Type | Description |
|---|---|
| RotationGestureHandler | Rotation gesture handler object. |
onActionUpdate
onActionUpdate(event: Callback<GestureEvent>): RotationGestureHandler
Sets the callback for rotation gesture movement updates. The callback is triggered when the rotation gesture moves.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<GestureEvent> | Yes | Callback invoked during rotation gesture movement. |
Return values
| Type | Description |
|---|---|
| RotationGestureHandler | Rotation gesture handler object. |
onActionEnd
onActionEnd(event: Callback<GestureEvent>): RotationGestureHandler
Sets the callback for rotation gesture recognition completion. This callback is triggered when all fingers are lifted after successful recognition.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<GestureEvent> | Yes | Callback invoked when rotation gesture recognition completes. |
Return values
| Type | Description |
|---|---|
| RotationGestureHandler | Rotation gesture handler object. |
onActionCancel
onActionCancel(event: Callback<void>): RotationGestureHandler
Sets the callback for rotation gesture cancellation. This callback is triggered when a touch cancellation event occurs after successful recognition. No gesture event information is returned.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<void> | Yes | Callback invoked when the rotation gesture is cancelled. No gesture event information is returned. |
Return values
| Type | Description |
|---|---|
| RotationGestureHandler | Rotation gesture handler object. |
onActionCancel18+
onActionCancel(event: Callback<GestureEvent>): RotationGestureHandler
Sets the callback for rotation gesture cancellation. This callback is triggered when a touch cancellation event occurs after successful recognition. Compared with onActionCancel, this API returns gesture event information.
Atomic service API: This API can be used in atomic services since API version 18.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<GestureEvent> | Yes | Callback invoked when the rotation gesture is cancelled. Gesture event information is returned. |
Return values
| Type | Description |
|---|---|
| RotationGestureHandler | Rotation gesture handler object. |
RotationGestureHandlerOptions
Provides the parameters of the rotation gesture handler. Inherits from BaseHandlerOptions.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| fingers | number | No | Yes | Minimum number of fingers required to trigger the rotation gesture. The value ranges from 2 to 5. Default value: 2 Value range: [2, 5] While more fingers than the minimum number can be pressed to trigger the gesture, only the first two fingers participate in gesture calculation. |
| angle | number | No | Yes | Minimum angle change required to trigger the rotation gesture, in degrees (deg). Default value: 1 NOTE If the value is less than or equal to 0 or greater than 360, it will be converted to the default value. |
| isFingerCountLimited15+ | boolean | No | Yes | Whether to enforce the exact number of fingers touching the screen. true: Enforce the exact number of fingers touching the screen. false: Do not enforce the exact number of fingers touching the screen. With the value true, the gesture recognition fails if the number of fingers touching the screen does not match the configured value of fingers. The gesture can only be successfully recognized if the number of fingers equals the configured minimum and the swipe distance meets the threshold. Note that only the first two fingers that touch the screen are considered for the gesture. If one of these fingers is lifted, the gesture recognition fails. For gestures that have already been successfully recognized, changing the number of fingers touching the screen will not trigger the onActionUpdate event, but the onActionEnd event can still be triggered. Default value: false Atomic service API: This API can be used in atomic services since API version 15. |
GestureGroupHandler
Defines a gesture group handler object.
constructor
constructor(options?: GestureGroupGestureHandlerOptions)
Constructor used to create a gesture group handler instance.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| options | GestureGroupGestureHandlerOptions | No | Parameters of the gesture group handler. |
onCancel
onCancel(event: Callback<void>): GestureGroupHandler
Sets the cancellation callback for the gesture group handler. The callback is triggered when a sequence gesture (GestureMode.Sequence) is cancelled.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | Callback<void> | Yes | Callback invoked when the gesture group is cancelled. |
Return values
| Type | Description |
|---|---|
| GestureGroupHandler | Current gesture group handler object. |
GestureGroupGestureHandlerOptions
Provides the parameters of the gesture group handler.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| mode | GestureMode | No | No | Recognition mode of combined gestures. Default value: GestureMode.Sequence |
| gestures | GestureHandler<TapGestureHandler | LongPressGestureHandler | PanGestureHandler | SwipeGestureHandler | PinchGestureHandler | RotationGestureHandler | GestureGroupHandler>[] | No | No | Gestures to be included in a gesture group. NOTE To add both single-tap and double-tap gestures for a component, add two TapGesture instances as the combined gestures, with the double-tap gesture preceding the single-tap gesture. The gestures will not work correctly if this order is reversed. |
GesturePriority
Enumerates gesture priority levels.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Value | Description |
|---|---|---|
| NORMAL | 0 | Normal priority. |
| PRIORITY | 1 | High priority. |