#[repr(C)]pub struct ArkUI_NativeGestureAPI_1 {Show 18 fields
pub version: i32,
pub createTapGesture: Option<unsafe extern "C" fn(countNum: i32, fingersNum: i32) -> *mut ArkUI_GestureRecognizer>,
pub createLongPressGesture: Option<unsafe extern "C" fn(fingersNum: i32, repeatResult: bool, durationNum: i32) -> *mut ArkUI_GestureRecognizer>,
pub createPanGesture: Option<unsafe extern "C" fn(fingersNum: i32, directions: ArkUI_GestureDirectionMask, distanceNum: f64) -> *mut ArkUI_GestureRecognizer>,
pub createPinchGesture: Option<unsafe extern "C" fn(fingersNum: i32, distanceNum: f64) -> *mut ArkUI_GestureRecognizer>,
pub createRotationGesture: Option<unsafe extern "C" fn(fingersNum: i32, angleNum: f64) -> *mut ArkUI_GestureRecognizer>,
pub createSwipeGesture: Option<unsafe extern "C" fn(fingersNum: i32, directions: ArkUI_GestureDirectionMask, speedNum: f64) -> *mut ArkUI_GestureRecognizer>,
pub createGroupGesture: Option<unsafe extern "C" fn(gestureMode: ArkUI_GroupGestureMode) -> *mut ArkUI_GestureRecognizer>,
pub dispose: Option<unsafe extern "C" fn(recognizer: *mut ArkUI_GestureRecognizer)>,
pub addChildGesture: Option<unsafe extern "C" fn(group: *mut ArkUI_GestureRecognizer, child: *mut ArkUI_GestureRecognizer) -> i32>,
pub removeChildGesture: Option<unsafe extern "C" fn(group: *mut ArkUI_GestureRecognizer, child: *mut ArkUI_GestureRecognizer) -> i32>,
pub setGestureEventTarget: Option<unsafe extern "C" fn(recognizer: *mut ArkUI_GestureRecognizer, actionTypeMask: ArkUI_GestureEventActionTypeMask, extraParams: *mut c_void, targetReceiver: Option<unsafe extern "C" fn(event: *mut ArkUI_GestureEvent, extraParams: *mut c_void)>) -> i32>,
pub addGestureToNode: Option<unsafe extern "C" fn(node: ArkUI_NodeHandle, recognizer: *mut ArkUI_GestureRecognizer, mode: ArkUI_GesturePriority, mask: ArkUI_GestureMask) -> i32>,
pub removeGestureFromNode: Option<unsafe extern "C" fn(node: ArkUI_NodeHandle, recognizer: *mut ArkUI_GestureRecognizer) -> i32>,
pub setGestureInterrupterToNode: Option<unsafe extern "C" fn(node: ArkUI_NodeHandle, interrupter: Option<unsafe extern "C" fn(info: *mut ArkUI_GestureInterruptInfo) -> ArkUI_GestureInterruptResult>) -> i32>,
pub getGestureType: Option<unsafe extern "C" fn(recognizer: *mut ArkUI_GestureRecognizer) -> ArkUI_GestureRecognizerType>,
pub setInnerGestureParallelTo: Option<unsafe extern "C" fn(node: ArkUI_NodeHandle, userData: *mut c_void, parallelInnerGesture: Option<unsafe extern "C" fn(event: *mut ArkUI_ParallelInnerGestureEvent) -> *mut ArkUI_GestureRecognizer>) -> i32>,
pub createTapGestureWithDistanceThreshold: Option<unsafe extern "C" fn(countNum: i32, fingersNum: i32, distanceThreshold: f64) -> *mut ArkUI_GestureRecognizer>,
}api-12 only.Expand description
Defines the gesture APIs.
Available since API-level: 12
Fields§
§version: i32The struct version is 1.
createTapGesture: Option<unsafe extern "C" fn(countNum: i32, fingersNum: i32) -> *mut ArkUI_GestureRecognizer>Creates a tap gesture.
-
This API is used to trigger a tap gesture with one, two, or more taps.
-
If multi-tap is configured, the timeout interval between a lift and the next tap is 300 ms.
-
If the distance between the last tapped position and the current tapped position exceeds 60 vp, gesture recognition fails.
-
If the value is greater than 1, the tap gesture will fail to be recognized when the number of fingers touching the screen within 300 ms of the first finger touch is less than the required number,
or when the number of fingers lifted from the screen within 300 ms of the first finger’s being lifted is less than the required number.
- When the number of fingers touching the screen exceeds the set value, the gesture can be recognized.
§Arguments
-
countNum- Indicates the number of consecutive taps. If the value is less than 1 or is not set, the default value 1 is used. -
fingersNum- Indicates the 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 1 is used.
§Returns
- Returns the pointer to the created gesture.
createLongPressGesture: Option<unsafe extern "C" fn(fingersNum: i32, repeatResult: bool, durationNum: i32) -> *mut ArkUI_GestureRecognizer>Creates a long press gesture.
-
This API is used to trigger a long press gesture, which requires one or more fingers with a minimum The value ranges 500 ms hold-down time.
-
In components that support drag actions by default, such as
, , , , , and RichEditor>, the long press gesture
may conflict with the drag action. If this occurs, they are handled as follows:
If the minimum duration of the long press gesture is less than 500 ms, the long press gesture receives a higher response priority than the drag action.
If the minimum duration of the long press gesture is greater than or equal to 500 ms, the drag action receives a higher response priority than the long press gesture.
- If a finger moves more than 15 px after being pressed, the gesture recognition fails.
§Arguments
-
fingersNum- Indicates the minimum number of fingers to trigger a long press gesture. The value ranges from 1 to 10. -
repeatResult- Indicates whether to continuously trigger the event callback. -
durationNum- Indicates the minimum hold-down time, in ms. If the value is less than or equal to 0, the default value 500 is used.
§Returns
- Returns the pointer to the created gesture.
createPanGesture: Option<unsafe extern "C" fn(fingersNum: i32, directions: ArkUI_GestureDirectionMask, distanceNum: f64) -> *mut ArkUI_GestureRecognizer>Creates a pan gesture.
-
This API is used to trigger a pan gesture when the movement distance of a finger on the screen exceeds the minimum value.
-
If a pan gesture and a tab swipe occur at the same time, set distanceNum to 1 so that the gesture can be more easily recognized.
§Arguments
-
fingersNum- Indicates the minimum number of fingers to trigger a pan gesture. The value ranges from 1 to 10. If the value is less than 1 or is not set, the default value 1 is used. -
directions- Indicates the pan direction. The value supports the AND (&) and OR (operations. -
distanceNum- Indicates the minimum pan distance to trigger the gesture, in vp. If this parameter is set to a value less than or equal to 0, the default value 5 is used.
§Returns
- Returns the pointer to the created gesture.
createPinchGesture: Option<unsafe extern "C" fn(fingersNum: i32, distanceNum: f64) -> *mut ArkUI_GestureRecognizer>Creates a pinch gesture.
-
This API is used to trigger a pinch gesture, which requires two to five fingers with a minimum 5 vp distance between the fingers.
-
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.
§Arguments
-
fingersNum- Indicates the minimum number of fingers to trigger a pinch. The value ranges from 2 to 5. Default value: 2 -
distanceNum- Indicates the minimum recognition distance, in px. If this parameter is set to a value less than or equal to 0, the default value 5 is used.
§Returns
- Returns the pointer to the created gesture.
createRotationGesture: Option<unsafe extern "C" fn(fingersNum: i32, angleNum: f64) -> *mut ArkUI_GestureRecognizer>Creates a rotation gesture.
-
This API is used to trigger a rotation gesture, which requires two to five fingers with a minimum 1-degree rotation angle.
-
While more fingers than the minimum number can be pressed to trigger the gesture, only the first two fingers participate in gesture calculation.
§Arguments
-
fingersNum- Indicates the minimum number of fingers to trigger a rotation. The value ranges from 2 to 5. Default value: 2 -
angleNum- Indicates the minimum degree that can trigger the rotation gesture. Default value: 1 If this parameter is set to a value less than or equal to 0 or greater than 360, the default value 1 is used.
§Returns
- Returns the pointer to the created gesture.
createSwipeGesture: Option<unsafe extern "C" fn(fingersNum: i32, directions: ArkUI_GestureDirectionMask, speedNum: f64) -> *mut ArkUI_GestureRecognizer>Creates a swipe gesture.
This API is used to implement a swipe gesture, which can be recognized when the swipe speed is 100 vp/s or higher.
§Arguments
-
fingersNum- Indicates the minimum number of fingers to trigger a swipe gesture. The value ranges from 1 to 10. -
directions- Indicates the swipe direction. -
speedNum- Indicates the minimum speed of the swipe gesture, in px/s. If this parameter is set to a value less than or equal to 0, the default value 100 is used.
§Returns
- Returns the pointer to the created gesture.
createGroupGesture: Option<unsafe extern "C" fn(gestureMode: ArkUI_GroupGestureMode) -> *mut ArkUI_GestureRecognizer>Creates a gesture group.
§Arguments
gestureMode- Indicates the gesture group mode.
§Returns
- Returns the pointer to the created gesture group.
dispose: Option<unsafe extern "C" fn(recognizer: *mut ArkUI_GestureRecognizer)>Disposes a gesture to release resources.
§Arguments
recognizer- Indicates the pointer to the gesture to dispose.
addChildGesture: Option<unsafe extern "C" fn(group: *mut ArkUI_GestureRecognizer, child: *mut ArkUI_GestureRecognizer) -> i32>Adds a gesture to a gesture group.
§Arguments
-
group- Indicates the pointer to the gesture group. -
child- Indicates the gesture to be added to the gesture group.
§Returns
- Returns 0 if success. Returns 401 if a parameter exception occurs. Returns 401 if a parameter exception occurs.
removeChildGesture: Option<unsafe extern "C" fn(group: *mut ArkUI_GestureRecognizer, child: *mut ArkUI_GestureRecognizer) -> i32>Removes a gesture to a gesture group.
§Arguments
-
group- Indicates the pointer to the gesture group. -
child- Indicates the gesture to be removed to the gesture group.
§Returns
- Returns 0 if success. Returns 401 if a parameter exception occurs.
setGestureEventTarget: Option<unsafe extern "C" fn(recognizer: *mut ArkUI_GestureRecognizer, actionTypeMask: ArkUI_GestureEventActionTypeMask, extraParams: *mut c_void, targetReceiver: Option<unsafe extern "C" fn(event: *mut ArkUI_GestureEvent, extraParams: *mut c_void)>) -> i32>Registers a callback for gestures.
§Arguments
-
recognizer- Indicates the pointer to the gesture recognizer. -
actionTypeMask- Indicates the set of gesture event types. Multiple callbacks can be registered at once, with the callback event types distinguished in the callbacks. Example: actionTypeMask = GESTURE_EVENT_ACTION_ACCEPT | GESTURE_EVENT_ACTION_UPDATE; -
extraParams- Indicates the context passed in the targetReceiver callback. -
targetReceiver- Indicates the callback to register for processing the gesture event types. event indicates the gesture callback data.
§Returns
- Returns 0 if success. Returns 401 if a parameter exception occurs.
addGestureToNode: Option<unsafe extern "C" fn(node: ArkUI_NodeHandle, recognizer: *mut ArkUI_GestureRecognizer, mode: ArkUI_GesturePriority, mask: ArkUI_GestureMask) -> i32>Adds a gesture to a UI component.
§Arguments
-
node- Indicates the UI component to which you want to add the gesture. -
recognizer- Indicates the gesture to be added to the UI component. -
mode- Indicates the gesture event mode. Available options are NORMAL_GESTURE, PARALLEL_GESTURE, and PRIORITY_GESTURE. -
mask- Indicates the gesture masking mode.
§Returns
- Returns 0 if success. Returns 401 if a parameter exception occurs.
removeGestureFromNode: Option<unsafe extern "C" fn(node: ArkUI_NodeHandle, recognizer: *mut ArkUI_GestureRecognizer) -> i32>Removes a gesture from a node.
§Arguments
-
node- Indicates the node from which you want to remove the gesture. -
recognizer- Indicates the gesture to be removed.
§Returns
- Returns 0 if success. Returns 401 if a parameter exception occurs.
setGestureInterrupterToNode: Option<unsafe extern "C" fn(node: ArkUI_NodeHandle, interrupter: Option<unsafe extern "C" fn(info: *mut ArkUI_GestureInterruptInfo) -> ArkUI_GestureInterruptResult>) -> i32>Sets a gesture interruption callback for a node.
§Arguments
-
node- Indicates the node for which you want to set a gesture interruption callback. -
interrupter- Indicates the gesture interruption callback to set. info indicates the gesture interruption data. If interrupter returns GESTURE_INTERRUPT_RESULT_CONTINUE, the gesture recognition process continues. If it returns GESTURE_INTERRUPT_RESULT_REJECT, the gesture recognition process is paused.
§Returns
- Returns 0 if success. Returns 401 if a parameter exception occurs.
getGestureType: Option<unsafe extern "C" fn(recognizer: *mut ArkUI_GestureRecognizer) -> ArkUI_GestureRecognizerType>Obtains the type of a gesture.
§Arguments
recognizer- Indicates the pointer to the gesture.
§Returns
- Returns the gesture type.
setInnerGestureParallelTo: Option<unsafe extern "C" fn(node: ArkUI_NodeHandle, userData: *mut c_void, parallelInnerGesture: Option<unsafe extern "C" fn(event: *mut ArkUI_ParallelInnerGestureEvent) -> *mut ArkUI_GestureRecognizer>) -> i32>Sets the callback function for a parallel internal gesture event.
§Arguments
-
node- Indicates the ArkUI node for which the callback of a parallel internal gesture event is to be set. -
userData- Indicates the custom data. -
parallelInnerGesture- Indicates the parallel internal gesture event. event returns the data of the parallel internal gesture event; parallelInnerGesture returns the pointer to the gesture recognizer that requires parallel recognition.
§Returns
- Returns [
ARKUI_ERROR_CODE_NO_ERROR] if success. Returns [ARKUI_ERROR_CODE_PARAM_INVALID] if a parameter exception occurs.
createTapGestureWithDistanceThreshold: Option<unsafe extern "C" fn(countNum: i32, fingersNum: i32, distanceThreshold: f64) -> *mut ArkUI_GestureRecognizer>Creates a tap gesture that is subject to distance restrictions.
-
This API is used to trigger a tap gesture with one, two, or more taps.
-
If multi-tap is configured, the timeout interval between a lift and the next tap is 300 ms.
-
If the distance between the last tapped position and the current tapped position exceeds 60 vp, gesture recognition fails.
-
If the value is greater than 1, the tap gesture will fail to be recognized when the number of fingers touching the screen within 300 ms of the first finger touch is less than the required number, or when the number of fingers lifted from the screen within 300 ms of the first finger’s being lifted is less than the required number.
-
When the number of fingers touching the screen exceeds the set value, the gesture can be recognized.
-
If the finger moves beyond the preset distance limit, gesture recognition fails.
§Arguments
-
countNum- Indicates the number of consecutive taps. If the value is less than 1 or is not set, the default value 1 is used. -
fingersNum- Indicates the 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 1 is used. -
distanceThreshold- Indicates the allowed moving distance of a finger. If the value is less than 0 or is not set, it will be converted to the default value of infinity.
§Returns
- Returns the pointer to the created gesture.