openharmony 鸿蒙 capi-native-gesture-h

2026-08-25 浏览 (1)

native_gesture.h

Overview

Declares the APIs of NativeGesture.

File to include: <arkui/native_gesture.h>

Library: libace_ndk.z.so

System capability: SystemCapability.ArkUI.ArkUI.Full

Since: 12

Related module: ArkUI_NativeModule

Summary

Structs

Nametypedef KeywordDescription
ArkUI_NativeGestureAPI_1ArkUI_NativeGestureAPI_1Defines the gesture APIs.
ArkUI_NativeGestureAPI_2-Defines the gesture APIs.
ArkUI_GestureRecognizerArkUI_GestureRecognizerDefines a gesture recognizer.
ArkUI_GestureInterruptInfoArkUI_GestureInterruptInfoDefines the gesture interruption information.
ArkUI_GestureEventArkUI_GestureEventDefines the gesture event.
ArkUI_GestureEventTargetInfoArkUI_GestureEventTargetInfoDefines a GestureEventTargetInfo object that provides information about a gesture event target.
ArkUI_ParallelInnerGestureEventArkUI_ParallelInnerGestureEventDefines a parallel built-in gesture event.
ArkUI_TouchRecognizerArkUI_TouchRecognizerDefines a touch recognizer.
ArkUI_TouchRecognizer*ArkUI_TouchRecognizerHandleDefines a touch recognizer handle.
ArkUI_TouchRecognizerHandle*ArkUI_TouchRecognizerHandleArrayDefines an array of touch recognizer handles.
ArkUI_GestureRecognizer*ArkUI_GestureRecognizerHandleDefines the gesture recognizer handle.
ArkUI_GestureRecognizerHandle*ArkUI_GestureRecognizerHandleArrayDefines the gesture recognizer handle array.

Enums

Nametypedef KeywordDescription
ArkUI_GestureEventActionTypeArkUI_GestureEventActionTypeEnumerates gesture event types.
ArkUI_GesturePriorityArkUI_GesturePriorityEnumerates gesture event modes.
ArkUI_GroupGestureModeArkUI_GroupGestureModeEnumerates gesture group modes.
ArkUI_GestureDirectionArkUI_GestureDirectionEnumerates gesture directions.
ArkUI_GestureMaskArkUI_GestureMaskEnumerates gesture masking modes.
ArkUI_GestureRecognizerTypeArkUI_GestureRecognizerTypeEnumerates gesture recognizer types.
ArkUI_GestureInterruptResultArkUI_GestureInterruptResultEnumerates gesture interruption results.
ArkUI_GestureRecognizerStateArkUI_GestureRecognizerStateEnumerates the gesture recognizer states.
OH_ArkUI_GestureCollectInterventionOH_ArkUI_GestureCollectInterventionDefines the intervention types for gesture and event collection.
Since: 26.0.0

Functions

Nametypedef KeywordDescription
typedef void (*ArkUI_GestureRecognizerDisposeNotifyCallback)(ArkUI_GestureRecognizer* recognizer, void* userData)ArkUI_GestureRecognizerDisposeNotifyCallbackDefines a callback function for notifying gesture recognizer destruction.
bool OH_ArkUI_GestureInterruptInfo_GetSystemFlag(const ArkUI_GestureInterruptInfo* event)-Checks whether a gesture is a system built-in gesture.
ArkUI_GestureRecognizer* OH_ArkUI_GestureInterruptInfo_GetRecognizer(const ArkUI_GestureInterruptInfo* event)-Obtains the pointer to the interrupted gesture recognizer.
ArkUI_GestureEvent* OH_ArkUI_GestureInterruptInfo_GetGestureEvent(const ArkUI_GestureInterruptInfo* event)-Obtains the pointer to the interrupted gesture event.
int32_t OH_ArkUI_GestureInterruptInfo_GetSystemRecognizerType(const ArkUI_GestureInterruptInfo* event)-Obtains the type of the system built-in gesture to trigger.
int32_t OH_ArkUI_GestureInterruptInfo_GetTouchRecognizers(const ArkUI_GestureInterruptInfo* info,ArkUI_TouchRecognizerHandleArray* recognizers, int32_t* size)-Obtains touch recognizers from gesture interruption information.
ArkUI_NodeHandle OH_ArkUI_TouchRecognizer_GetNodeHandle(const ArkUI_TouchRecognizerHandle recognizer)-Obtains the component handle corresponding to a touch recognizer.
int32_t OH_ArkUI_TouchRecognizer_CancelTouch(ArkUI_TouchRecognizerHandle recognizer, ArkUI_GestureInterruptInfo* info)-Sends a cancel touch event to a touch recognizer in a gesture interruption callback.
ArkUI_GestureEventActionType OH_ArkUI_GestureEvent_GetActionType(const ArkUI_GestureEvent* event)-Obtains the gesture event type.
const ArkUI_UIInputEvent* OH_ArkUI_GestureEvent_GetRawInputEvent(const ArkUI_GestureEvent* event)-Obtains gesture input.
int32_t OH_ArkUI_LongPress_GetRepeatCount(const ArkUI_GestureEvent* event)-Checks whether the event is a repeated trigger event.
float OH_ArkUI_PanGesture_GetVelocity(const ArkUI_GestureEvent* event)-Obtains the velocity of a pan gesture along the main axis.
float OH_ArkUI_PanGesture_GetVelocityX(const ArkUI_GestureEvent* event)-Obtains the velocity of a pan gesture along the x-axis.
float OH_ArkUI_PanGesture_GetVelocityY(const ArkUI_GestureEvent* event)-Obtains the velocity of a pan gesture along the y-axis.
float OH_ArkUI_PanGesture_GetOffsetX(const ArkUI_GestureEvent* event)-Obtains the relative offset of a pan gesture along the x-axis.
float OH_ArkUI_PanGesture_GetOffsetY(const ArkUI_GestureEvent* event)-Obtains the relative offset of a pan gesture along the y-axis.
float OH_ArkUI_SwipeGesture_GetAngle(const ArkUI_GestureEvent* event)-Obtains the angle information of the swipe gesture. After a swipe gesture is recognized, a line connecting the two fingers is identified as the initial line. As the fingers swipe, the line between the fingers rotates.
Based on the coordinates of the initial line's and current line's end points, the arc tangent function is used to calculate the respective included angle of the points relative to the horizontal direction
by using the following formula: Rotation angle = arctan2(cy2-cy1,cx2-cx1) - arctan2(y2-y1,x2-x1).
The initial line is used as the coordinate system. The clockwise rotation is 0 to 180 degrees, and the counter-clockwise rotation is -180 to 0 degrees.
float OH_ArkUI_SwipeGesture_GetVelocity(const ArkUI_GestureEvent* event)-Obtains the average velocity of all fingers used in the swipe gesture.
float OH_ArkUI_RotationGesture_GetAngle(const ArkUI_GestureEvent* event)-Obtains the angle information of a rotation gesture.
float OH_ArkUI_PinchGesture_GetScale(const ArkUI_GestureEvent* event)-Obtains the scale ratio of a pinch gesture.
float OH_ArkUI_PinchGesture_GetCenterX(const ArkUI_GestureEvent* event)-Obtains the x-coordinate of the center of the pinch gesture, in vp, relative to the upper left corner of the current component.
float OH_ArkUI_PinchGesture_GetCenterY(const ArkUI_GestureEvent* event)-Obtains the y-coordinate of the center of the pinch gesture, in vp, relative to the upper left corner of the current component.
ArkUI_NodeHandle OH_ArkUI_GestureEvent_GetNode(const ArkUI_GestureEvent* event)-Obtains the ArkUI component to which the gesture is bound.
int32_t OH_ArkUI_GetResponseRecognizersFromInterruptInfo(const ArkUI_GestureInterruptInfo* event,ArkUI_GestureRecognizerHandleArray* responseChain, int32_t* count)-Obtains information about a gesture response chain.
int32_t OH_ArkUI_SetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer, bool enabled)-Sets the enabled state of a gesture recognizer.
int32_t OH_ArkUI_SetGestureRecognizerLimitFingerCount(ArkUI_GestureRecognizer* recognizer, bool limitFingerCount)-Sets whether to enable strict finger count checking. If this feature is enabled and the actual number of touch fingers does not match the set number, the gesture recognition fails.
bool OH_ArkUI_GetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer)-Obtains the enabled state of a gesture recognizer.
int32_t OH_ArkUI_GetGestureRecognizerState(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureRecognizerState* state)-Obtains the state of a gesture recognizer.
int32_t OH_ArkUI_GetGestureEventTargetInfo(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureEventTargetInfo** info)-Obtains the information about a gesture event target.
int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollBegin(ArkUI_GestureEventTargetInfo* info, bool* ret)-Obtains whether this scrollable container component is scrolled to the top.
int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollEnd(ArkUI_GestureEventTargetInfo* info, bool* ret)-Obtains whether this scrollable container component is scrolled to the bottom.
int32_t OH_ArkUI_GetPanGestureDirectionMask(ArkUI_GestureRecognizer* recognizer,ArkUI_GestureDirectionMask* directionMask)-Obtains the direction of a pan gesture.
bool OH_ArkUI_IsBuiltInGesture(ArkUI_GestureRecognizer* recognizer)-Obtains whether a gesture is a built-in gesture.
int32_t OH_ArkUI_GetGestureTag(ArkUI_GestureRecognizer* recognizer, char* buffer, int32_t bufferSize, int32_t* result)-Obtains the tag of a gesture recognizer.
int32_t OH_ArkUI_GetGestureBindNodeId(ArkUI_GestureRecognizer* recognizer, char* nodeId, int32_t size,int32_t* result)-Obtains the ID of the component linked to a gesture recognizer.
bool OH_ArkUI_IsGestureRecognizerValid(ArkUI_GestureRecognizer* recognizer)-Obtains whether a gesture recognizer is valid.
void* OH_ArkUI_ParallelInnerGestureEvent_GetUserData(ArkUI_ParallelInnerGestureEvent* event)-Obtains custom data in the parallel built-in gesture event.
ArkUI_GestureRecognizer* OH_ArkUI_ParallelInnerGestureEvent_GetCurrentRecognizer(ArkUI_ParallelInnerGestureEvent* event)-Obtains the current gesture recognizer in a parallel built-in gesture event.
int32_t OH_ArkUI_ParallelInnerGestureEvent_GetConflictRecognizers(ArkUI_ParallelInnerGestureEvent* event,ArkUI_GestureRecognizerHandleArray* array, int32_t* size)-Obtains the conflicting gesture recognizers in a parallel built-in gesture event.
int32_t OH_ArkUI_SetArkUIGestureRecognizerDisposeNotify(ArkUI_GestureRecognizer* recognizer,ArkUI_GestureRecognizerDisposeNotifyCallback callback, void* userData)-Sets a callback function for notifying gesture recognizer destruction.
int32_t OH_ArkUI_GetGestureParam_DirectMask(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureDirectionMask* directMask)-Obtains the swipe direction of a gesture recognizer.
int32_t OH_ArkUI_GetGestureParam_FingerCount(ArkUI_GestureRecognizer* recognizer, int* finger)-Obtains the number of fingers used by a gesture recognizer.
int32_t OH_ArkUI_GetGestureParam_limitFingerCount(ArkUI_GestureRecognizer* recognizer, bool* isLimited)-Checks whether a gesture recognizer has a finger count limit.
int32_t OH_ArkUI_GetGestureParam_repeat(ArkUI_GestureRecognizer* recognizer, bool* isRepeat)-Checks whether a gesture recognizer continuously triggers event callbacks.
int32_t OH_ArkUI_GetGestureParam_distance(ArkUI_GestureRecognizer* recognizer, double* distance)-Obtains the allowed movement distance range for a gesture recognizer.
int32_t OH_ArkUI_GetGestureParam_speed(ArkUI_GestureRecognizer* recognizer, double* speed)-Obtains the minimum swipe speed recognized by a gesture recognizer.
int32_t OH_ArkUI_GetGestureParam_duration(ArkUI_GestureRecognizer* recognizer, int* duration)-Obtains the minimum duration required to trigger a long press by a gesture recognizer.
int32_t OH_ArkUI_GetGestureParam_angle(ArkUI_GestureRecognizer* recognizer, double* angle)-Obtains the minimum angle change required for a rotation gesture to be recognized by a gesture recognizer.
int32_t OH_ArkUI_GetGestureParam_distanceThreshold(ArkUI_GestureRecognizer* recognizer, double* distanceThreshold)-Obtains the movement threshold distance for gesture recognition.
ArkUI_ErrorCode OH_ArkUI_PanGesture_SetDistanceMap(ArkUI_GestureRecognizer* recognizer, int size, int* toolTypeArray, double* distanceArray)-Sets the minimum sliding distance threshold mapping for gesture recognition.
ArkUI_ErrorCode OH_ArkUI_PanGesture_GetDistanceByToolType(ArkUI_GestureRecognizer* recognizer, int toolType, double* distance)-Obtains the movement distance threshold for gesture recognition for a specific input device type. This API only returns values for device types previously set using OH_ArkUI_PanGesture_SetDistanceMap. The default pan gesture activation threshold can be obtained using UI_INPUT_EVENT_TOOL_TYPE_UNKNOWN. This API returns no value for unconfigured device types.
ArkUI_ErrorCode OH_ArkUI_SetTouchTestDoneCallback(ArkUI_NodeHandle node,void* userData,void (*touchTestDone)(ArkUI_GestureEvent* event,ArkUI_GestureRecognizerHandleArray recognizers,int32_t count,void* userData))-Registers a callback that is executed after all gesture recognizers are collected. When the user begins touching the screen, the system performs hit testing and collects gesture recognizers based on the touch location. Subsequently, before processing any move events, the component can use this API to determine the gesture recognizers that will participate in and compete for recognition.
void* OH_ArkUI_GestureInterrupter_GetUserData(ArkUI_GestureInterruptInfo* event)-Obtains the custom data from a gesture interruption event.
ArkUI_ErrorCode OH_ArkUI_PreventGestureRecognizerBegin(ArkUI_GestureRecognizer* recognizer)-Prevents a gesture recognizer from participating in the current gesture recognition before all fingers are lifted. If the system has already determined the result of the gesture recognizer (regardless of success or failure), calling this API will be ineffective.
ArkUI_ErrorCode OH_ArkUI_LongPressGesture_SetAllowableMovement(ArkUI_GestureRecognizer* recognizer, double allowableMovement)-Sets the maximum movement distance allowed for gesture recognition by the long press gesture recognizer.
ArkUI_ErrorCode OH_ArkUI_LongPressGesture_GetAllowableMovement(ArkUI_GestureRecognizer* recognizer, double* allowableMovement)-Obtains the maximum movement distance allowed for gesture recognition by the long press gesture recognizer.
ArkUI_ErrorCode OH_ArkUI_GestureCollectInterceptInfo_GetResponseRecognizers(const ArkUI_GestureCollectInterceptInfo* info, ArkUI_GestureRecognizerHandleArray* array, int32_t* size)-Obtains gesture recognizer handles from gesture collection interception information.
Since: 26.0.0
ArkUI_ErrorCode OH_ArkUI_GestureCollectInterceptInfo_GetTouchRecognizers(const ArkUI_GestureCollectInterceptInfo* info, ArkUI_TouchRecognizerHandleArray* recognizers, int32_t* size)-Obtains touch recognizer handles from gesture collection interception information.
Since: 26.0.0
ArkUI_ErrorCode OH_ArkUI_GestureCollectInterceptInfo_SetGestureCollectIntervention(ArkUI_GestureCollectInterceptInfo* info, OH_ArkUI_GestureCollectIntervention intervention)-Sets the intervention mode for gesture collection.
Since: 26.0.0
ArkUI_ErrorCode OH_ArkUI_GetGestureBindNodeUniqueId(const ArkUI_GestureRecognizer* recognizer, int32_t* uniqueId)-Obtains the unique ID of the component bound to a gesture recognizer.
Since: 26.0.0
bool OH_ArkUI_TouchRecognizer_IsHostBelongsTo(const ArkUI_TouchRecognizerHandle recognizer, int32_t uniqueId)-Checks whether the node bound to the touch recognizer is a descendant node of the passed component.
Since: 26.0.0
bool OH_ArkUI_GestureRecognizer_IsHostBelongsTo(const ArkUI_GestureRecognizer* recognizer, int32_t uniqueId)-Checks whether the node bound to the gesture recognizer is a descendant node of the passed component.
Since: 26.0.0

Variables

Nametypedef KeywordDescription
uint32_tArkUI_GestureDirectionMaskDefines a set of gesture directions.
Example: ArkUI_GestureDirectionMask directions = GESTURE_DIRECTION_LEFT |GESTURE_DIRECTION_RIGHT
This example indicates that the leftward and rightward directions are supported.
uint32_tArkUI_GestureEventActionTypeMaskDefines a set of gesture event types. Example: ArkUI_GestureEventActionTypeMask actions = GESTURE_EVENT_ACTION_ACCEPT |GESTURE_EVENT_ACTION_UPDATE

Example

NameDescription
NdkGestureSettingExamples demonstrating gesture binding, gesture removal, and custom gesture detection are added since API version 20.
NdkGestureNestScrollExamples demonstrating nested scrolling through gesture APIs are added since API version 20.
NdkGestureBlockingExamples demonstrating gesture interception are added since API version 20.

Enum Description

ArkUI_GestureEventActionType

enum ArkUI_GestureEventActionType

Description

Enumerates gesture event types.

Since: 12

ValueDescription
GESTURE_EVENT_ACTION_ACCEPT = 0x01Triggered.
GESTURE_EVENT_ACTION_UPDATE = 0x02Updated.
GESTURE_EVENT_ACTION_END = 0x04Ended.
GESTURE_EVENT_ACTION_CANCEL = 0x08Canceled.

ArkUI_GesturePriority

enum ArkUI_GesturePriority

Description

Enumerates gesture event modes.

Since: 12

ValueDescription
NORMAL = 0Normal.
PRIORITY = 1High priority.
PARALLEL = 2Parallel.

ArkUI_GroupGestureMode

enum ArkUI_GroupGestureMode

Description

Enumerates gesture group modes.

Since: 12

ValueDescription
SEQUENTIAL_GROUP = 0Sequential recognition. Gestures are recognized in the registration sequence until all gestures are recognized successfully. Once one gesture fails to be recognized, all subsequent gestures fail to be recognized. Only the last gesture in the gesture group can respond to the end event.
PARALLEL_GROUP = 1Parallel recognition. Registered gestures are recognized concurrently until all gestures are recognized. The recognition result of each gesture does not affect each other.
EXCLUSIVE_GROUP = 2Exclusive recognition. Registered gestures are identified concurrently. If one gesture is successfully recognized, gesture recognition ends.

ArkUI_GestureDirection

enum ArkUI_GestureDirection

Description

Enumerates gesture directions.

Since: 12

ValueDescription
GESTURE_DIRECTION_ALL = 0b1111All directions.
GESTURE_DIRECTION_HORIZONTAL = 0b0011Horizontal direction.
GESTURE_DIRECTION_VERTICAL = 0b1100Vertical direction.
GESTURE_DIRECTION_LEFT = 0b0001Leftward.
GESTURE_DIRECTION_RIGHT = 0b0010Rightward.
GESTURE_DIRECTION_UP = 0b0100Upward.
GESTURE_DIRECTION_DOWN = 0b1000Downward.
GESTURE_DIRECTION_NONE = 0None.

ArkUI_GestureMask

enum ArkUI_GestureMask

Description

Enumerates gesture masking modes.

Since: 12

ValueDescription
NORMAL_GESTURE_MASK = 0The gestures of child components are enabled and recognized based on the default gesture recognition sequence.
IGNORE_INTERNAL_GESTURE_MASK = 1The gestures of child components are disabled, including the built-in gestures.

ArkUI_GestureRecognizerType

enum ArkUI_GestureRecognizerType

Description

Enumerates gesture recognizer types.

Since: 12

ValueDescription
TAP_GESTURE = 0Tap.
LONG_PRESS_GESTURE = 1Long press.
PAN_GESTURE = 2Pan.
PINCH_GESTURE = 3Pinch.
ROTATION_GESTURE = 4Rotate.
SWIPE_GESTURE = 5Swipe.
GROUP_GESTURE = 6A group of gestures.
CLICK_GESTURE = 7Click gesture registered with onClick.
Since: 20
DRAG_DROP = 8Drag-and-drop gesture.
Since: 20

OH_ArkUI_GestureCollectIntervention

enum OH_ArkUI_GestureCollectIntervention

Description

Defines the intervention types for gesture and event collection.

Since: 26.0.0

ValueDescription
OH_ARKUI_GESTURE_COLLECT_INTERVENTION_CONTINUE = 0Continues the normal gesture and event collection flow. No intervention is performed.
OH_ARKUI_GESTURE_COLLECT_INTERVENTION_DISCARD_LOWER = 1Discards all low-priority gestures and events to be collected.
The gestures of the left sibling node and ancestor nodes (parent nodes and above) are discarded.
Only the gestures already collected on the current node and higher-priority nodes are retained.
OH_ARKUI_GESTURE_COLLECT_INTERVENTION_DISCARD_HIGHER = 2Discards all collected high-priority gestures and events.
The gestures of the right sibling node and the current node are discarded.
Continues processing the collection flow for lower-priority gestures (left sibling and ancestor nodes).
OH_ARKUI_GESTURE_COLLECT_INTERVENTION_DISCARD_SELF = 3Discards the gestures and events of the current node.
The gestures and events of the current node are excluded from the gesture tree.
The gestures of the sibling nodes (left and right) and the ancestor nodes are still collected.
OH_ARKUI_GESTURE_COLLECT_INTERVENTION_DISCARD_LOWER_PRIORITY_SIBLINGS = 4Discards the gestures and events to be collected from the left sibling node.
The gestures and events of the current node and the collected gestures and events of the right sibling node are retained.
Continues processing the collection flow for the parent and ancestor nodes.

ArkUI_GestureInterruptResult

enum ArkUI_GestureInterruptResult

Description

Enumerates gesture interruption results.

Since: 12

ValueDescription
GESTURE_INTERRUPT_RESULT_CONTINUE = 0The gesture recognition process continues.
GESTURE_INTERRUPT_RESULT_REJECT = 1The gesture recognition process is paused.

ArkUI_GestureRecognizerState

enum ArkUI_GestureRecognizerState

Description

Enumerates the gesture recognizer states.

Since: 12

ValueDescription
ARKUI_GESTURE_RECOGNIZER_STATE_READY = 0Ready.
ARKUI_GESTURE_RECOGNIZER_STATE_DETECTING = 1Detecting.
ARKUI_GESTURE_RECOGNIZER_STATE_PENDING = 2Pending.
ARKUI_GESTURE_RECOGNIZER_STATE_BLOCKED = 3Blocked.
ARKUI_GESTURE_RECOGNIZER_STATE_SUCCESSFUL = 4Successful.
ARKUI_GESTURE_RECOGNIZER_STATE_FAILED = 5Failed.

Function Description

ArkUI_GestureRecognizerDisposeNotifyCallback()

typedef void (*ArkUI_GestureRecognizerDisposeNotifyCallback)(ArkUI_GestureRecognizer* recognizer, void* userData)

Description

Defines a callback function for notifying gesture recognizer destruction.

Since: 12

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
void* userDataPointer to user-defined data.

OH_ArkUI_GestureInterruptInfo_GetSystemFlag()

bool OH_ArkUI_GestureInterruptInfo_GetSystemFlag(const ArkUI_GestureInterruptInfo* event)

Description

Checks whether a gesture is a system built-in gesture.

Since: 12

Parameters

NameDescription
const ArkUI_GestureInterruptInfo* eventPointer to the gesture interruption callback event.

Returns

TypeDescription
booltrue: built-in gesture.
false: non-built-in gesture.

OH_ArkUI_GestureInterruptInfo_GetRecognizer()

ArkUI_GestureRecognizer* OH_ArkUI_GestureInterruptInfo_GetRecognizer(const ArkUI_GestureInterruptInfo* event)

Description

Obtains the pointer to the interrupted gesture recognizer.

Since: 12

Parameters

NameDescription
const ArkUI_GestureInterruptInfo* eventPointer to the gesture interruption callback event.

Returns

TypeDescription
ArkUI_GestureRecognizer*Pointer to the interrupted gesture recognizer.

OH_ArkUI_GestureInterruptInfo_GetGestureEvent()

ArkUI_GestureEvent* OH_ArkUI_GestureInterruptInfo_GetGestureEvent(const ArkUI_GestureInterruptInfo* event)

Description

Obtains the pointer to the interrupted gesture event.

Since: 12

Parameters

NameDescription
const ArkUI_GestureInterruptInfo* eventPointer to the gesture interruption callback event.

Returns

TypeDescription
ArkUI_GestureEvent*Pointer to the interrupted gesture event.

OH_ArkUI_GestureInterruptInfo_GetSystemRecognizerType()

int32_t OH_ArkUI_GestureInterruptInfo_GetSystemRecognizerType(const ArkUI_GestureInterruptInfo* event)

Description

Obtains the type of the system built-in gesture to trigger.

Since: 12

Parameters

NameDescription
const ArkUI_GestureInterruptInfo* eventPointer to the gesture interruption callback event.

Returns

TypeDescription
int32_tType of the system built-in gesture to trigger. The value is defined in ArkUI_GestureRecognizerType. If the triggered gesture is not a built-in gesture, -1 is returned.

OH_ArkUI_GestureInterruptInfo_GetTouchRecognizers()

int32_t OH_ArkUI_GestureInterruptInfo_GetTouchRecognizers(const ArkUI_GestureInterruptInfo* info,ArkUI_TouchRecognizerHandleArray* recognizers, int32_t* size)

Description

Obtains touch recognizers from gesture interruption information.

Since: 15

Parameters

NameDescription
const ArkUI_GestureInterruptInfo* infoPointer to the gesture interruption information.
ArkUI_TouchRecognizerHandleArray* recognizersPointer to the touch recognizer handle array.
int32_t* sizePointer to the size of the touch recognizer array.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_TouchRecognizer_GetNodeHandle()

ArkUI_NodeHandle OH_ArkUI_TouchRecognizer_GetNodeHandle(const ArkUI_TouchRecognizerHandle recognizer)

Description

Obtains the component handle corresponding to a touch recognizer.

Since: 15

Parameters

NameDescription
const ArkUI_TouchRecognizerHandle recognizerHandle to the touch recognizer.

Returns

TypeDescription
ArkUI_NodeHandleComponent handle corresponding to the touch recognizer.

OH_ArkUI_TouchRecognizer_CancelTouch()

int32_t OH_ArkUI_TouchRecognizer_CancelTouch(ArkUI_TouchRecognizerHandle recognizer, ArkUI_GestureInterruptInfo* info)

Description

Sends a cancel touch event to a touch recognizer in a gesture interruption callback.

Since: 15

Parameters

NameDescription
ArkUI_TouchRecognizerHandle recognizerHandle to the touch recognizer.
ArkUI_GestureInterruptInfo* infoPointer to the gesture interruption information.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_GestureEvent_GetActionType()

ArkUI_GestureEventActionType OH_ArkUI_GestureEvent_GetActionType(const ArkUI_GestureEvent* event)

Description

Obtains the gesture event type.

Since: 12

Parameters

NameDescription
const ArkUI_GestureEvent* eventPointer to the gesture event.

Returns

TypeDescription
ArkUI_GestureEventActionTypeType of the gesture event.

OH_ArkUI_GestureEvent_GetRawInputEvent()

const ArkUI_UIInputEvent* OH_ArkUI_GestureEvent_GetRawInputEvent(const ArkUI_GestureEvent* event)

Description

Obtains gesture input.

Since: 12

Parameters

NameDescription
const ArkUI_GestureEvent* eventPointer to the gesture event.

Returns

TypeDescription
const ArkUI_UIInputEvent*Pointer to the input event of the gesture event.

OH_ArkUI_LongPress_GetRepeatCount()

int32_t OH_ArkUI_LongPress_GetRepeatCount(const ArkUI_GestureEvent* event)

Description

Checks whether the event is a repeated trigger event.

Since: 12

Parameters

NameDescription
const ArkUI_GestureEvent* eventPointer to the gesture event.

Returns

TypeDescription
int32_tWhether the event is a repeated trigger event. The value 1 means that the event is a repeated trigger event, and 0 means the opposite.

OH_ArkUI_PanGesture_GetVelocity()

float OH_ArkUI_PanGesture_GetVelocity(const ArkUI_GestureEvent* event)

Description

Obtains the velocity of a pan gesture along the main axis.

Since: 12

Parameters

NameDescription
const ArkUI_GestureEvent* eventPointer to the gesture event.

Returns

TypeDescription
floatVelocity of the pan gesture along the main axis, in px/s. The value is the square root of the sum of the squares of the velocity on the x-axis and y-axis.

OH_ArkUI_PanGesture_GetVelocityX()

float OH_ArkUI_PanGesture_GetVelocityX(const ArkUI_GestureEvent* event)

Description

Obtains the velocity of a pan gesture along the x-axis.

Since: 12

Parameters

NameDescription
const ArkUI_GestureEvent* eventPointer to the gesture event.

Returns

TypeDescription
floatVelocity of the pan gesture along the x-axis, in px/s.

OH_ArkUI_PanGesture_GetVelocityY()

float OH_ArkUI_PanGesture_GetVelocityY(const ArkUI_GestureEvent* event)

Description

Obtains the velocity of a pan gesture along the y-axis.

Since: 12

Parameters

NameDescription
const ArkUI_GestureEvent* eventPointer to the gesture event.

Returns

TypeDescription
floatVelocity of the pan gesture along the y-axis, in px/s.

OH_ArkUI_PanGesture_GetOffsetX()

float OH_ArkUI_PanGesture_GetOffsetX(const ArkUI_GestureEvent* event)

Description

Obtains the relative offset of a pan gesture along the x-axis.

Since: 12

Parameters

NameDescription
const ArkUI_GestureEvent* eventPointer to the gesture event.

Returns

TypeDescription
floatRelative offset of the gesture along the x-axis, in px.

OH_ArkUI_PanGesture_GetOffsetY()

float OH_ArkUI_PanGesture_GetOffsetY(const ArkUI_GestureEvent* event)

Description

Obtains the relative offset of a pan gesture along the y-axis.

Since: 12

Parameters

NameDescription
const ArkUI_GestureEvent* eventPointer to the gesture event.

Returns

TypeDescription
floatRelative offset of the gesture along the y-axis, in px.

OH_ArkUI_SwipeGesture_GetAngle()

float OH_ArkUI_SwipeGesture_GetAngle(const ArkUI_GestureEvent* event)

Description

Obtains the angle information of the swipe gesture. After a swipe gesture is recognized, a line connecting the two fingers is identified as the initial line. As the fingers swipe, the line between the fingers rotates.
Based on the coordinates of the initial line's and current line's end points, the arc tangent function is used to calculate the respective included angle of the points relative to the horizontal direction
by using the following formula: Rotation angle = arctan2(cy2-cy1,cx2-cx1) - arctan2(y2-y1,x2-x1).
The initial line is used as the coordinate system. The clockwise rotation is 0 to 180 degrees, and the counter-clockwise rotation is -180 to 0 degrees.

Since: 12

Parameters

NameDescription
const ArkUI_GestureEvent* eventPointer to the gesture event.

Returns

TypeDescription
floatAngle of the swipe gesture, which is the result obtained based on the aforementioned formula. The unit is deg.

OH_ArkUI_SwipeGesture_GetVelocity()

float OH_ArkUI_SwipeGesture_GetVelocity(const ArkUI_GestureEvent* event)

Description

Obtains the average velocity of all fingers used in the swipe gesture.

Since: 12

Parameters

NameDescription
const ArkUI_GestureEvent* eventPointer to the gesture event.

Returns

TypeDescription
floatAverage velocity of all fingers used in the swipe gesture, in px/s.

OH_ArkUI_RotationGesture_GetAngle()

float OH_ArkUI_RotationGesture_GetAngle(const ArkUI_GestureEvent* event)

Description

Obtains the angle information of a rotation gesture.

Since: 12

Parameters

NameDescription
const ArkUI_GestureEvent* eventPointer to the gesture event.

Returns

TypeDescription
floatRotation angle. The unit is deg.

OH_ArkUI_PinchGesture_GetScale()

float OH_ArkUI_PinchGesture_GetScale(const ArkUI_GestureEvent* event)

Description

Obtains the scale ratio of a pinch gesture.

Since: 12

Parameters

NameDescription
const ArkUI_GestureEvent* eventPointer to the gesture event.

Returns

TypeDescription
floatScale factor.

OH_ArkUI_PinchGesture_GetCenterX()

float OH_ArkUI_PinchGesture_GetCenterX(const ArkUI_GestureEvent* event)

Description

Obtains the x-coordinate of the center of the pinch gesture, in vp, relative to the upper left corner of the current component.

Since: 12

Parameters

NameDescription
const ArkUI_GestureEvent* eventPointer to the gesture event.

Returns

TypeDescription
floatX-coordinate of the center of the pinch gesture, in px, relative to the upper left corner of the current component.

OH_ArkUI_PinchGesture_GetCenterY()

float OH_ArkUI_PinchGesture_GetCenterY(const ArkUI_GestureEvent* event)

Description

Obtains the y-coordinate of the center of the pinch gesture, in vp, relative to the upper left corner of the current component.

Since: 12

Parameters

NameDescription
const ArkUI_GestureEvent* eventPointer to the gesture event.

Returns

TypeDescription
floatY-coordinate of the center of the pinch gesture, in px, relative to the upper left corner of the current component.

OH_ArkUI_GestureEvent_GetNode()

ArkUI_NodeHandle OH_ArkUI_GestureEvent_GetNode(const ArkUI_GestureEvent* event)

Description

Obtains the ArkUI component to which the gesture is bound.

Since: 12

Parameters

NameDescription
const ArkUI_GestureEvent* eventPointer to the gesture event.

Returns

TypeDescription
ArkUI_NodeHandleArkUI component to which the gesture is bound. Returns NULL if the event is invalid.

OH_ArkUI_GetResponseRecognizersFromInterruptInfo()

int32_t OH_ArkUI_GetResponseRecognizersFromInterruptInfo(const ArkUI_GestureInterruptInfo* event,ArkUI_GestureRecognizerHandleArray* responseChain, int32_t* count)

Description

Obtains information about a gesture response chain.

Since: 12

Parameters

NameDescription
const ArkUI_GestureInterruptInfo* eventPointer to the gesture interruption callback event.
ArkUI_GestureRecognizerHandleArray* responseChainPointer to an array of gesture recognizer handles on the response chain.
int32_t* countPointer to the number of gesture recognizer handles on the response chain.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_SetGestureRecognizerEnabled()

int32_t OH_ArkUI_SetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer, bool enabled)

Description

Sets the enabled state of a gesture recognizer.

Since: 12

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
bool enabledEnabled state. The value true means that the gesture recognizer is enabled, and false means the opposite.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_SetGestureRecognizerLimitFingerCount()

int32_t OH_ArkUI_SetGestureRecognizerLimitFingerCount(ArkUI_GestureRecognizer* recognizer, bool limitFingerCount)

Description

Sets whether to enable strict finger count checking. If this feature is enabled and the actual number of touch fingers does not match the set number, the gesture recognition fails.

Since: 15

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
bool limitFingerCountWhether to enable strict finger count checking.
true: Enforce the exact number of fingers touching the screen.
false: Do not enforce the exact number of fingers touching the screen.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_GetGestureRecognizerEnabled()

bool OH_ArkUI_GetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer)

Description

Obtains the enabled state of a gesture recognizer.

Since: 12

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.

Returns

TypeDescription
booltrue: enabled.
false: disabled.

OH_ArkUI_GetGestureRecognizerState()

int32_t OH_ArkUI_GetGestureRecognizerState(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureRecognizerState* state)

Description

Obtains the state of a gesture recognizer.

Since: 12

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
ArkUI_GestureRecognizerState* statePointer to the state of the gesture recognizer.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_GetGestureEventTargetInfo()

int32_t OH_ArkUI_GetGestureEventTargetInfo(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureEventTargetInfo** info)

Description

Obtains the information about a gesture event target.

Since: 12

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
ArkUI_GestureEventTargetInfo** infoDouble pointer to the information about a gesture event target.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_GestureEventTargetInfo_IsScrollBegin()

int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollBegin(ArkUI_GestureEventTargetInfo* info, bool* ret)

Description

Obtains whether this scrollable container component is scrolled to the top.

Since: 12

Parameters

NameDescription
ArkUI_GestureEventTargetInfo* infoPointer to the information about a gesture event target.
bool* retPointer to the parameter indicating whether this scrollable container component is scrolled to the top. The value true means that the component is scrolled to the top, and false means the opposite.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.
Returns ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER if the component is not a scrollable container.

OH_ArkUI_GestureEventTargetInfo_IsScrollEnd()

int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollEnd(ArkUI_GestureEventTargetInfo* info, bool* ret)

Description

Obtains whether this scrollable container component is scrolled to the bottom.

Since: 12

Parameters

NameDescription
ArkUI_GestureEventTargetInfo* infoPointer to the information about a gesture event target.
bool* retPointer to the parameter indicating whether this scrollable container component is scrolled to the bottom. The value true means that the component is scrolled to the bottom, and false means the opposite.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.
Returns ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER if the component is not a scrollable container.

OH_ArkUI_GetPanGestureDirectionMask()

int32_t OH_ArkUI_GetPanGestureDirectionMask(ArkUI_GestureRecognizer* recognizer,ArkUI_GestureDirectionMask* directionMask)

Description

Obtains the direction of a pan gesture.

Since: 12

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
ArkUI_GestureDirectionMask* directionMaskPointer to the pan direction.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_IsBuiltInGesture()

bool OH_ArkUI_IsBuiltInGesture(ArkUI_GestureRecognizer* recognizer)

Description

Obtains whether a gesture is a built-in gesture.

Since: 12

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.

Returns

TypeDescription
booltrue: built-in gesture.
false: non-built-in gesture.

OH_ArkUI_GetGestureTag()

int32_t OH_ArkUI_GetGestureTag(ArkUI_GestureRecognizer* recognizer, char* buffer, int32_t bufferSize, int32_t* result)

Description

Obtains the tag of a gesture recognizer.

Since: 12

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
char* bufferPointer to the output buffer.
int32_t bufferSizeSize of the output buffer.
int32_t* resultPointer to the length of the copied string.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.
Returns ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH if the buffer is not large enough.

OH_ArkUI_GetGestureBindNodeId()

int32_t OH_ArkUI_GetGestureBindNodeId(ArkUI_GestureRecognizer* recognizer, char* nodeId, int32_t size,int32_t* result)

Description

Obtains the ID of the component linked to a gesture recognizer.

Since: 12

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
char* nodeIdPointer to the component ID.
int32_t sizeSize of the output buffer.
int32_t* resultPointer to the length of the copied string.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.
Returns ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH if the buffer is not large enough.

OH_ArkUI_IsGestureRecognizerValid()

bool OH_ArkUI_IsGestureRecognizerValid(ArkUI_GestureRecognizer* recognizer)

Description

Obtains whether a gesture recognizer is valid.

Since: 12

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.

Returns

TypeDescription
booltrue: The gesture recognizer is valid.
false: The gesture recognizer is invalid.

OH_ArkUI_ParallelInnerGestureEvent_GetUserData()

void* OH_ArkUI_ParallelInnerGestureEvent_GetUserData(ArkUI_ParallelInnerGestureEvent* event)

Description

Obtains custom data in the parallel built-in gesture event.

Since: 12

Parameters

NameDescription
ArkUI_ParallelInnerGestureEvent* eventPointer to the parallel built-in gesture event.

Returns

TypeDescription
void*Pointer to user-defined data.

OH_ArkUI_ParallelInnerGestureEvent_GetCurrentRecognizer()

ArkUI_GestureRecognizer* OH_ArkUI_ParallelInnerGestureEvent_GetCurrentRecognizer(ArkUI_ParallelInnerGestureEvent* event)

Description

Obtains the current gesture recognizer in a parallel built-in gesture event.

Since: 12

Parameters

NameDescription
ArkUI_ParallelInnerGestureEvent* eventPointer to the parallel built-in gesture event.

Returns

TypeDescription
ArkUI_GestureRecognizer*Pointer to the current gesture recognizer.

OH_ArkUI_ParallelInnerGestureEvent_GetConflictRecognizers()

int32_t OH_ArkUI_ParallelInnerGestureEvent_GetConflictRecognizers(ArkUI_ParallelInnerGestureEvent* event,ArkUI_GestureRecognizerHandleArray* array, int32_t* size)

Description

Obtains the conflicting gesture recognizers in a parallel built-in gesture event.

Since: 12

Parameters

NameDescription
ArkUI_ParallelInnerGestureEvent* eventPointer to the parallel built-in gesture event.
ArkUI_GestureRecognizerHandleArray* arrayPointer to the array of conflicting gesture recognizers.
int32_t* sizePointer to the size of the array of conflicting gesture recognizers.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_SetArkUIGestureRecognizerDisposeNotify()

int32_t OH_ArkUI_SetArkUIGestureRecognizerDisposeNotify(ArkUI_GestureRecognizer* recognizer,ArkUI_GestureRecognizerDisposeNotifyCallback callback, void* userData)

Description

Sets a callback function for notifying gesture recognizer destruction.

Since: 12

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
ArkUI_GestureRecognizerDisposeNotifyCallback callbackCallback function for notifying gesture recognizer destruction.
void* userDataPointer to user-defined data.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_GetGestureParam_DirectMask()

int32_t OH_ArkUI_GetGestureParam_DirectMask(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureDirectionMask* directMask)

Description

Obtains the swipe direction of a gesture recognizer.

Since: 18

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
ArkUI_GestureDirectionMask* directMaskPointer to the swipe direction of the gesture recognizer.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_GetGestureParam_FingerCount()

int32_t OH_ArkUI_GetGestureParam_FingerCount(ArkUI_GestureRecognizer* recognizer, int* finger)

Description

Obtains the number of fingers used by a gesture recognizer.

Since: 18

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
int* fingerPointer to the number of fingers used by the gesture recognizer.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_GetGestureParam_limitFingerCount()

int32_t OH_ArkUI_GetGestureParam_limitFingerCount(ArkUI_GestureRecognizer* recognizer, bool* isLimited)

Description

Checks whether a gesture recognizer has a finger count limit.

Since: 18

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
bool* isLimitedPointer to the parameter indicating whether the gesture recognizer has a finger count limit. true indicates that the gesture recognizer has a finger count limit. false indicates that the gesture recognizer does not have a finger count limit.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_GetGestureParam_repeat()

int32_t OH_ArkUI_GetGestureParam_repeat(ArkUI_GestureRecognizer* recognizer, bool* isRepeat)

Description

Checks whether a gesture recognizer continuously triggers event callbacks.

Since: 18

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
bool* isRepeatPointer to the parameter indicating whether the gesture recognizer continuously triggers event callbacks. The value true means to continuously trigger event callbacks, and false means the opposite.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED if the gesture recognizer type is not supported.

OH_ArkUI_GetGestureParam_distance()

int32_t OH_ArkUI_GetGestureParam_distance(ArkUI_GestureRecognizer* recognizer, double* distance)

Description

Obtains the allowed movement distance range for a gesture recognizer.

Since: 18

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
double* distancePointer to the allowed movement distance range of the gesture recognizer. The unit is px.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED if the gesture recognizer type is not supported.

OH_ArkUI_GetGestureParam_speed()

int32_t OH_ArkUI_GetGestureParam_speed(ArkUI_GestureRecognizer* recognizer, double* speed)

Description

Obtains the minimum swipe speed recognized by a gesture recognizer.

Since: 18

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
double* speedPointer to the minimum swipe speed recognized by the gesture recognizer. The unit is px/s.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED if the gesture recognizer type is not supported.

OH_ArkUI_GetGestureParam_duration()

int32_t OH_ArkUI_GetGestureParam_duration(ArkUI_GestureRecognizer* recognizer, int* duration)

Description

Obtains the minimum duration required to trigger a long press by a gesture recognizer.

Since: 18

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
int* durationPointer to the minimum duration for a long press. The unit is ms.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED if the gesture recognizer type is not supported.

OH_ArkUI_GetGestureParam_angle()

int32_t OH_ArkUI_GetGestureParam_angle(ArkUI_GestureRecognizer* recognizer, double* angle)

Description

Obtains the minimum angle change required for a rotation gesture to be recognized by a gesture recognizer.

Since: 18

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
double* anglePointer to the minimum angle change. The unit is deg.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED if the gesture recognizer type is not supported.

OH_ArkUI_GetGestureParam_distanceThreshold()

int32_t OH_ArkUI_GetGestureParam_distanceThreshold(ArkUI_GestureRecognizer* recognizer, double* distanceThreshold)

Description

Obtains the movement threshold distance for gesture recognition.

Since: 18

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
double* distanceThresholdPointer to the movement distance threshold of the gesture recognizer. The unit is px.

Returns

TypeDescription
int32_tResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED if the gesture recognizer type is not supported.

OH_ArkUI_PanGesture_SetDistanceMap()

ArkUI_ErrorCode OH_ArkUI_PanGesture_SetDistanceMap(ArkUI_GestureRecognizer* recognizer, int size, int* toolTypeArray, double* distanceArray)

Description

Sets the minimum sliding distance threshold mapping for gesture recognition.

Since: 19

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
int sizeSize of the array of minimum sliding distance thresholds.
int* toolTypeArrayPointer to the array of tool types for which thresholds are set. If a value other than UI_INPUT_EVENT_TOOL_TYPE_XXX is set, the setting does not take effect.
double* distanceArrayPointer to the array of minimum sliding distances. The unit is px.

Returns

TypeDescription
ArkUI_ErrorCodeResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.
Returns ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED if the gesture recognizer type is not supported.

OH_ArkUI_PanGesture_GetDistanceByToolType()

ArkUI_ErrorCode OH_ArkUI_PanGesture_GetDistanceByToolType(ArkUI_GestureRecognizer* recognizer, int toolType, double* distance)

Description

Obtains the movement distance threshold for gesture recognition for a specific input device type. This API only returns values for device types previously set using OH_ArkUI_PanGesture_SetDistanceMap. The default movement distance threshold can be obtained by querying the UI_INPUT_EVENT_TOOL_TYPE_UNKNOWN type. Other types that have not been set are not returned.

Since: 19

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
int toolTypeTool type for which you want to obtain the threshold.
double* distancePointer to the movement distance threshold of the gesture recognizer. The unit is px.

Returns

TypeDescription
ArkUI_ErrorCodeResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.
Returns ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED if the gesture recognizer type is not supported.

OH_ArkUI_SetTouchTestDoneCallback()

ArkUI_ErrorCode OH_ArkUI_SetTouchTestDoneCallback(ArkUI_NodeHandle node, void* userData, void (*touchTestDone)(ArkUI_GestureEvent* event, ArkUI_GestureRecognizerHandleArray recognizers, int32_t count, void* userData))

Description

Registers a callback that is executed after all gesture recognizers are collected. When the user begins touching the screen, the system performs hit testing and collects gesture recognizers based on the touch location. Subsequently, before processing any move events, the component can use this API to determine the gesture recognizers that will participate in and compete for recognition.

Since: 20

Parameters

NameDescription
ArkUI_NodeHandle nodeHandle to the node on which the callback is to be set.
void* userDataPointer to user-defined data.
void (*touchTestDone)(ArkUI_GestureEvent* event, ArkUI_GestureRecognizerHandleArray recognizers, int32_t count, void* userData)Callback for completion of gesture recognizer collection. event indicates the basic information about the gesture, recognizers indicates the gesture recognizer array, count indicates the number of gesture recognizers, and userData indicates the user-defined data.

Returns

TypeDescription
ArkUI_ErrorCodeResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_GestureInterrupter_GetUserData()

void* OH_ArkUI_GestureInterrupter_GetUserData(ArkUI_GestureInterruptInfo* event)

Description

Obtains the custom data from a gesture interruption event.

Since: 18

Parameters

NameDescription
ArkUI_GestureInterruptInfo* eventPointer to the gesture interruption information.

Returns

TypeDescription
void*Pointer to user-defined data.

OH_ArkUI_PreventGestureRecognizerBegin()

ArkUI_ErrorCode OH_ArkUI_PreventGestureRecognizerBegin(ArkUI_GestureRecognizer* recognizer)

Description

Prevents a gesture recognizer from participating in the current gesture recognition before all fingers are lifted. If the system has already determined the result of the gesture recognizer (regardless of success or failure), calling this API will be ineffective.

Since: 20

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.

Returns

TypeDescription
ArkUI_ErrorCodeResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_LongPressGesture_SetAllowableMovement()

ArkUI_ErrorCode OH_ArkUI_LongPressGesture_SetAllowableMovement(ArkUI_GestureRecognizer* recognizer, double allowableMovement)

Description

Sets the maximum movement distance allowed for gesture recognition by the long press gesture recognizer.

Since: 22

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
double allowableMovementMaximum movement distance allowed for gesture recognition by the long press gesture recognizer.
The unit is px.
Value range: (0, +∞). If the value is less than or equal to 0, the default value 15 is used.

Returns

TypeDescription
ArkUI_ErrorCodeResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.
Returns ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED if the gesture recognizer type is not supported.

OH_ArkUI_LongPressGesture_GetAllowableMovement()

ArkUI_ErrorCode OH_ArkUI_LongPressGesture_GetAllowableMovement(ArkUI_GestureRecognizer* recognizer, double* allowableMovement)

Description

Obtains the maximum movement distance allowed for gesture recognition by the long press gesture recognizer.

Since: 22

Parameters

NameDescription
ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer instance.
double* allowableMovementPointer to the maximum movement distance allowed for gesture recognition by the long press gesture recognizer.

Returns

TypeDescription
ArkUI_ErrorCodeResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.
Returns ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED if the gesture recognizer type is not supported.

OH_ArkUI_GestureCollectInterceptInfo_GetResponseRecognizers()

ArkUI_ErrorCode OH_ArkUI_GestureCollectInterceptInfo_GetResponseRecognizers(const ArkUI_GestureCollectInterceptInfo* info, ArkUI_GestureRecognizerHandleArray* array, int32_t* size)

Description

Obtains gesture recognizer handles from gesture collection interception information.

Since: 26.0.0

Parameters

NameDescription
const ArkUI_GestureCollectInterceptInfo* infoPointer to the gesture collection interception information.
ArkUI_GestureRecognizerHandleArray* arrayPointer to the gesture recognizer handle array.
int32_t* sizePointer to the size of the gesture recognizer handle array.

Returns

TypeDescription
ArkUI_ErrorCodeARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_GestureCollectInterceptInfo_GetTouchRecognizers()

ArkUI_ErrorCode OH_ArkUI_GestureCollectInterceptInfo_GetTouchRecognizers(const ArkUI_GestureCollectInterceptInfo* info, ArkUI_TouchRecognizerHandleArray* recognizers, int32_t* size)

Description

Obtains touch recognizer handles from gesture collection interception information.

Since: 26.0.0

Parameters

NameDescription
const ArkUI_GestureCollectInterceptInfo* infoPointer to the gesture collection interception information.
ArkUI_TouchRecognizerHandleArray* recognizersPointer to the touch recognizer handle array.
int32_t* sizePointer to the size of the touch recognizer handle array.

Returns

TypeDescription
ArkUI_ErrorCodeARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_GestureCollectInterceptInfo_SetGestureCollectIntervention()

ArkUI_ErrorCode OH_ArkUI_GestureCollectInterceptInfo_SetGestureCollectIntervention(ArkUI_GestureCollectInterceptInfo* info, OH_ArkUI_GestureCollectIntervention intervention)

Description

Sets the intervention mode for gesture collection.

Since: 26.0.0

Parameters

NameDescription
ArkUI_GestureCollectInterceptInfo* infoPointer to the gesture collection interception information.
OH_ArkUI_GestureCollectIntervention interventionGesture collection intervention mode, which is of the OH_ArkUI_GestureCollectIntervention type.

Returns

TypeDescription
ArkUI_ErrorCodeARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_GetGestureBindNodeUniqueId()

ArkUI_ErrorCode OH_ArkUI_GetGestureBindNodeUniqueId(const ArkUI_GestureRecognizer* recognizer, int32_t* uniqueId)

Description

Obtains the unique ID of the component bound to a gesture recognizer.

Since: 26.0.0

Parameters

NameDescription
const ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer.
int32_t* uniqueIdPointer to the unique ID of the component bound to the gesture recognizer.

Returns

TypeDescription
ArkUI_ErrorCodeARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

OH_ArkUI_TouchRecognizer_IsHostBelongsTo()

bool OH_ArkUI_TouchRecognizer_IsHostBelongsTo(const ArkUI_TouchRecognizerHandle recognizer, int32_t uniqueId)

Description

Checks whether the node bound to the touch recognizer is a descendant node of the passed component.

Since: 26.0.0

Parameters

NameDescription
const ArkUI_TouchRecognizerHandle recognizerTouch recognizer handle.
int32_t uniqueIdUnique ID of the component.

Returns

TypeDescription
booltrue if the node bound to the touch recognizer is a descendant node of the passed component; false otherwise.

OH_ArkUI_GestureRecognizer_IsHostBelongsTo()

bool OH_ArkUI_GestureRecognizer_IsHostBelongsTo(const ArkUI_GestureRecognizer* recognizer, int32_t uniqueId)

Description

Checks whether the node bound to the gesture recognizer is a descendant node of the passed component.

Since: 26.0.0

Parameters

NameDescription
const ArkUI_GestureRecognizer* recognizerPointer to the gesture recognizer.
int32_t uniqueIdUnique ID of the component.

Returns

TypeDescription
booltrue if the node bound to the gesture recognizer is a descendant node of the passed component; false otherwise.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 arkts-apis-uicontext-contextmenucontroller

openharmony 鸿蒙 errorcode-canvas

openharmony 鸿蒙 capi-oh-nativexcomponent-native-xcomponent-oh-nativexcomponent

openharmony 鸿蒙 errorcode-bindSheet

openharmony 鸿蒙 js-apis-arkui-uiExtension-sys

openharmony 鸿蒙 capi-arkui-accessibility-arkui-accessibilityeventinfo

openharmony 鸿蒙 capi-arkui-rendernodeutils

openharmony 鸿蒙 js-apis-arkui-node

openharmony 鸿蒙 capi-native-node-h

openharmony 鸿蒙 capi-arkui-nativemodule-arkui-listitemswipeactionitem

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/bSG9OOWw