目录

ArkUI_NativeGestureAPI_2

typedef struct {...} ArkUI_NativeGestureAPI_2

Overview

Defines a collection of gesture APIs. Based on ArkUI_NativeGestureAPI_1, the capability of setting a gesture interruption event callback is extended, which is used to continue or interrupt a gesture based on the callback result during gesture processing. You can access basic gesture APIs through gestureApi1 and use setGestureInterrupterToNode to implement complete gesture interruption handling.

Since: 18

Related module: ArkUI_NativeModule

Header file: native_gesture.h

Summary

[h2]Member Variables

Name Description
ArkUI_NativeGestureAPI_1* gestureApi1 Pointer to the ArkUI_NativeGestureAPI_1 struct.

[h2]Member Functions

Member Function Description

[h2]setGestureInterrupterToNode()

int32_t (*setGestureInterrupterToNode)(ArkUI_NodeHandle node, void* userData, ArkUI_GestureInterruptResult (*interrupter)(ArkUI_GestureInterruptInfo* info))

Description

Sets the callback function for gesture interruption event. It is applicable to scenarios where you need to decide, based on the current interaction state during gesture recognition, whether the gesture continues to respond or is interrupted, for example, handling gesture response conflicts.

Parameters

Name Description
ArkUI_NodeHandle node Pointer to the ArkUI node for which you want to set a gesture interruption callback.
void* userData Pointer to the user-defined data, which is used to associate the caller's custom context data when setting the gesture interruption callback, for use by the callback to execute its processing logic. If no context needs to be associated, pass a null pointer.
ArkUI_GestureInterruptResult (*interrupter)(ArkUI_GestureInterruptInfo* info)

Pointer to the gesture interruption callback function. info returns the gesture interruption data. If interrupter returns GESTURE_INTERRUPT_RESULT_CONTINUE, the gesture recognition process continues, which is suitable for scenarios where the gesture is allowed to continue response. If it returns GESTURE_INTERRUPT_RESULT_REJECT, the gesture recognition process is paused, which is suitable for scenarios where other gestures or interactions need to be handled first. If this parameter is set to a null pointer, the callback function is unregistered.

Note: After the gesture interruption callback function is registered, it will be available in subsequent single-gesture processing. That is, even if you reset the callback function to nullptr through setGestureInterrupterToNode in the same gesture processing flow or use the dispose API to dispose of the gesture that is about to be triggered, the callback function will still respond when the trigger condition is met. If the object referenced in the callback function may have been released before the callback is triggered, ensure that the object can still be safely accessed while the callback function is being triggered.

Return value

Type Description
int32_t

Result code.

Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.

Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.