1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup ArkUI_NativeModule 18 * @{ 19 * 20 * @brief Defines APIs for ArkUI to register gesture callbacks on the native side. 21 * 22 * @since 12 23 */ 24 25 /** 26 * @file native_gesture.h 27 * 28 * @brief Provides type definitions for <b>NativeGesture</b> APIs. 29 * 30 * @library libace_ndk.z.so 31 * @syscap SystemCapability.ArkUI.ArkUI.Full 32 * @since 12 33 */ 34 35 #ifndef ARKUI_NATIVE_GESTTURE_H 36 #define ARKUI_NATIVE_GESTTURE_H 37 38 #include "ui_input_event.h" 39 #include "native_type.h" 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 /** 46 * @brief Defines a gesture recognizer. 47 * 48 * @since 12 49 */ 50 typedef struct ArkUI_GestureRecognizer ArkUI_GestureRecognizer; 51 52 /** 53 * @brief Defines the gesture interruption information. 54 * 55 * @since 12 56 */ 57 typedef struct ArkUI_GestureInterruptInfo ArkUI_GestureInterruptInfo; 58 59 /** 60 * @brief Defines the gesture event. 61 * 62 * @since 12 63 */ 64 typedef struct ArkUI_GestureEvent ArkUI_GestureEvent; 65 66 /** 67 * @brief Enumerates gesture event types. 68 * 69 * @since 12 70 */ 71 typedef enum { 72 /** Triggered. */ 73 GESTURE_EVENT_ACTION_ACCEPT = 0x01, 74 75 /** Updated. */ 76 GESTURE_EVENT_ACTION_UPDATE = 0x02, 77 78 /** Ended. */ 79 GESTURE_EVENT_ACTION_END = 0x04, 80 81 /** Canceled. */ 82 GESTURE_EVENT_ACTION_CANCEL = 0x08, 83 } ArkUI_GestureEventActionType; 84 85 /** 86 * @brief Defines a set of gesture event types. 87 * 88 * Example: ArkUI_GestureEventActionTypeMask actions = GESTURE_EVENT_ACTION_ACCEPT | GESTURE_EVENT_ACTION_UPDATE;\n 89 * 90 * @since 12 91 */ 92 typedef uint32_t ArkUI_GestureEventActionTypeMask; 93 94 /** 95 * @brief Enumerates gesture event modes. 96 * 97 * @since 12 98 */ 99 typedef enum { 100 /** Normal. */ 101 NORMAL = 0, 102 103 /** High-priority. */ 104 PRIORITY = 1, 105 106 /** Parallel. */ 107 PARALLEL = 2, 108 } ArkUI_GesturePriority; 109 110 /** 111 * @brief Enumerates gesture group modes. 112 * 113 * @since 12 114 */ 115 typedef enum { 116 /* Sequential recognition. Gestures are recognized in the registration sequence until all gestures are recognized 117 * successfully. Once one gesture fails to be recognized, all subsequent gestures fail to be recognized. 118 * Only the last gesture in the gesture group can respond to the end event. */ 119 SEQUENTIAL_GROUP = 0, 120 121 /** Parallel recognition. Registered gestures are recognized concurrently until all gestures are recognized. 122 * The recognition result of each gesture does not affect each other. */ 123 PARALLEL_GROUP = 1, 124 125 /** Exclusive recognition. Registered gestures are identified concurrently. 126 * If one gesture is successfully recognized, gesture recognition ends. */ 127 EXCLUSIVE_GROUP = 2, 128 } ArkUI_GroupGestureMode; 129 130 /** 131 * @brief Enumerates gesture directions. 132 * 133 * @since 12 134 */ 135 typedef enum { 136 /** All directions. */ 137 GESTURE_DIRECTION_ALL = 0b1111, 138 139 /** Horizontal direction. */ 140 GESTURE_DIRECTION_HORIZONTAL = 0b0011, 141 142 /** Vertical direction. */ 143 GESTURE_DIRECTION_VERTICAL = 0b1100, 144 145 /** Leftward. */ 146 GESTURE_DIRECTION_LEFT = 0b0001, 147 148 /** Rightward. */ 149 GESTURE_DIRECTION_RIGHT = 0b0010, 150 151 /** Upward. */ 152 GESTURE_DIRECTION_UP = 0b0100, 153 154 /** Downward. */ 155 GESTURE_DIRECTION_DOWN = 0b1000, 156 157 /** None. */ 158 GESTURE_DIRECTION_NONE = 0, 159 } ArkUI_GestureDirection; 160 161 /** 162 * @brief Defines a set of gesture directions. 163 * 164 * Example: ArkUI_GestureDirectionMask directions = GESTURE_DIRECTION_LEFT | GESTURE_DIRECTION_RIGHT \n 165 * This example indicates that the leftward and rightward directions are supported. \n 166 * 167 * @since 12 168 */ 169 typedef uint32_t ArkUI_GestureDirectionMask; 170 171 /** 172 * @brief Enumerates gesture masking modes. 173 * 174 * @since 12 175 */ 176 typedef enum { 177 /** The gestures of child components are enabled and recognized based on the default gesture recognition sequence.*/ 178 NORMAL_GESTURE_MASK = 0, 179 180 /** The gestures of child components are disabled, including the built-in gestures. */ 181 IGNORE_INTERNAL_GESTURE_MASK, 182 } ArkUI_GestureMask; 183 184 /** 185 * @brief Enumerates gesture types. 186 * 187 * @since 12 188 */ 189 typedef enum { 190 /** Tap. */ 191 TAP_GESTURE = 0, 192 193 /** Long press. */ 194 LONG_PRESS_GESTURE, 195 196 /** Pan. */ 197 PAN_GESTURE, 198 199 /** Pinch. */ 200 PINCH_GESTURE, 201 202 /** Rotate. */ 203 ROTATION_GESTURE, 204 205 /** Swipe. */ 206 SWIPE_GESTURE, 207 208 /** A group of gestures. */ 209 GROUP_GESTURE, 210 } ArkUI_GestureRecognizerType; 211 212 /** 213 * @brief Enumerates gesture interruption results. 214 * 215 * @since 12 216 */ 217 typedef enum { 218 /** The gesture recognition process continues. */ 219 GESTURE_INTERRUPT_RESULT_CONTINUE = 0, 220 221 /** The gesture recognition process is paused. */ 222 GESTURE_INTERRUPT_RESULT_REJECT, 223 } ArkUI_GestureInterruptResult; 224 225 /** 226 * @brief Enumerates the gesture recognizer states. 227 * 228 * @since 12 229 */ 230 typedef enum { 231 /** Ready. */ 232 ARKUI_GESTURE_RECOGNIZER_STATE_READY = 0, 233 234 /** Detecting. */ 235 ARKUI_GESTURE_RECOGNIZER_STATE_DETECTING = 1, 236 237 /** Pending. */ 238 ARKUI_GESTURE_RECOGNIZER_STATE_PENDING = 2, 239 240 /** Blocked. */ 241 ARKUI_GESTURE_RECOGNIZER_STATE_BLOCKED = 3, 242 243 /** Successful. */ 244 ARKUI_GESTURE_RECOGNIZER_STATE_SUCCESSFUL = 4, 245 246 /** Failed. */ 247 ARKUI_GESTURE_RECOGNIZER_STATE_FAILED = 5, 248 } ArkUI_GestureRecognizerState; 249 250 /** 251 * @brief Defines the gesture recognizer handle. 252 * 253 * @since 12 254 */ 255 typedef ArkUI_GestureRecognizer* ArkUI_GestureRecognizerHandle; 256 257 /** 258 * @brief Defines the gesture recognizer handle array. 259 * 260 * @since 12 261 */ 262 typedef ArkUI_GestureRecognizerHandle* ArkUI_GestureRecognizerHandleArray; 263 264 /** 265 * @brief Defines a <b>GestureEventTargetInfo</b> object that provides information about a gesture event target. 266 * 267 * @since 12 268 */ 269 typedef struct ArkUI_GestureEventTargetInfo ArkUI_GestureEventTargetInfo; 270 271 /** 272 * @brief Defines a parallel internal gesture event. 273 * 274 * @since 12 275 */ 276 typedef struct ArkUI_ParallelInnerGestureEvent ArkUI_ParallelInnerGestureEvent; 277 278 /** 279 * @brief Defines a touch recognizer. 280 * 281 * @since 15 282 */ 283 typedef struct ArkUI_TouchRecognizer ArkUI_TouchRecognizer; 284 285 /** 286 * @brief Defines a touch recognizer handle. 287 * 288 * @since 15 289 */ 290 typedef ArkUI_TouchRecognizer* ArkUI_TouchRecognizerHandle; 291 292 /** 293 * @brief Defines an array of touch recognizer handle. 294 * 295 * @since 15 296 */ 297 typedef ArkUI_TouchRecognizerHandle* ArkUI_TouchRecognizerHandleArray; 298 299 /** 300 * @brief Defines a callback function for notifying gesture recognizer destruction. 301 * @since 12 302 */ 303 typedef void (*ArkUI_GestureRecognizerDisposeNotifyCallback)(ArkUI_GestureRecognizer* recognizer, void* userData); 304 305 /** 306 * @brief Checks whether a gesture is a built-in gesture of the component. 307 * 308 * @param event Indicates the pointer to the gesture interruption information. 309 * @return Returns <b>true</b> if the gesture is a built-in gesture; returns <b>false</b> otherwise. 310 311 * @since 12 312 */ 313 bool OH_ArkUI_GestureInterruptInfo_GetSystemFlag(const ArkUI_GestureInterruptInfo* event); 314 315 /** 316 * @brief Obtains the pointer to interrupted gesture recognizer. 317 * 318 * @param event Indicates the pointer to the gesture interruption information. 319 * @return Returns the pointer to interrupted gesture recognizer. 320 * @since 12 321 */ 322 ArkUI_GestureRecognizer* OH_ArkUI_GestureInterruptInfo_GetRecognizer(const ArkUI_GestureInterruptInfo* event); 323 324 /** 325 * @brief Obtains the pointer to the interrupted gesture event. 326 * 327 * @param event Indicates the pointer to the gesture interruption information. 328 * @return Returns the pointer to the interrupted gesture event. 329 * @since 12 330 */ 331 ArkUI_GestureEvent* OH_ArkUI_GestureInterruptInfo_GetGestureEvent(const ArkUI_GestureInterruptInfo* event); 332 333 /** 334 * @brief Obtains the type of the system gesture to trigger. 335 * 336 * @param event Indicates the pointer to the gesture interruption information. 337 * @return Returns the type of the system gesture to trigger. If the gesture to trigger is not a system gesture, 338 * <b>-1</b> is returned. 339 * @since 12 340 */ 341 int32_t OH_ArkUI_GestureInterruptInfo_GetSystemRecognizerType(const ArkUI_GestureInterruptInfo* event); 342 343 /** 344 * @brief Get the touch recognizer handles from the gesture interrupt info. 345 * 346 * @param info Indicates the pointer to a gesture interrupt info. 347 * @param recognizers Indicates the array of touch recognizer handles. 348 * @param size Indicates the size of recognizers. 349 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. 350 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. 351 * @since 15 352 */ 353 int32_t OH_ArkUI_GestureInterruptInfo_GetTouchRecognizers( 354 const ArkUI_GestureInterruptInfo* info, ArkUI_TouchRecognizerHandleArray* recognizers, int32_t* size); 355 356 /** 357 * @brief Get component object of the specific touch recognizer. 358 * 359 * @param recognizer Indicates the pointer to the TouchRecognizer. 360 * @return Get component object of the specific touch recognizer. 361 * @since 15 362 */ 363 ArkUI_NodeHandle OH_ArkUI_TouchRecognizer_GetNodeHandle(const ArkUI_TouchRecognizerHandle recognizer); 364 365 /** 366 * @brief Send touch-cancel event to the touch recognizer in a gesture interruption callback. 367 * 368 * @param recognizer Indicates the touch recognizer handle. 369 * @param info Indicates the pointer to a gesture interrupt info. 370 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. 371 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. 372 * @since 15 373 */ 374 int32_t OH_ArkUI_TouchRecognizer_CancelTouch(ArkUI_TouchRecognizerHandle recognizer, ArkUI_GestureInterruptInfo* info); 375 376 /** 377 * @brief Obtains the gesture event type. 378 * 379 * @param event Indicates the pointer to the gesture event. 380 * @return Returns the gesture event type. 381 * @since 12 382 */ 383 ArkUI_GestureEventActionType OH_ArkUI_GestureEvent_GetActionType(const ArkUI_GestureEvent* event); 384 385 /** 386 * @brief Obtains gesture input. 387 * 388 * @param event Indicates the pointer to the gesture event. 389 * @return Returns the pointer to the input event of the gesture event. 390 * @since 12 391 */ 392 const ArkUI_UIInputEvent* OH_ArkUI_GestureEvent_GetRawInputEvent(const ArkUI_GestureEvent* event); 393 394 /** 395 * @brief Obtains the number of times that a long press gesture is triggered periodically. 396 * 397 * @param event Indicates the pointer to the gesture event. 398 * @return Returns the number of times that the long press gesture is triggered periodically. 399 * @since 12 400 */ 401 int32_t OH_ArkUI_LongPress_GetRepeatCount(const ArkUI_GestureEvent* event); 402 403 /** 404 * @brief Obtains the velocity of a pan gesture along the main axis. 405 * 406 * @param event Indicates the pointer to the gesture event. 407 * @return Returns the velocity of the pan gesture along the main axis, in px/s. 408 * The value is the square root of the sum of the squares of the velocity on the x-axis and y-axis. 409 * @since 12 410 */ 411 float OH_ArkUI_PanGesture_GetVelocity(const ArkUI_GestureEvent* event); 412 413 /** 414 * @brief Obtains the velocity of a pan gesture along the x-axis. 415 * 416 * @param event Indicates the pointer to the gesture event. 417 * @return Returns the velocity of the pan gesture along the x-axis, in px/s. 418 * @since 12 419 */ 420 float OH_ArkUI_PanGesture_GetVelocityX(const ArkUI_GestureEvent* event); 421 422 /** 423 * @brief Obtains the velocity of a pan gesture along the y-axis. 424 * 425 * @param event Indicates the pointer to the gesture event. 426 * @return Returns the velocity of the pan gesture along the y-axis, in px/s. 427 * @since 12 428 */ 429 float OH_ArkUI_PanGesture_GetVelocityY(const ArkUI_GestureEvent* event); 430 431 /** 432 * @brief Obtains the relative offset of a pan gesture along the x-axis. 433 * 434 * @param event Indicates the pointer to the gesture event. 435 * @return Returns the relative offset of the gesture along the x-axis, in px. 436 * @since 12 437 */ 438 float OH_ArkUI_PanGesture_GetOffsetX(const ArkUI_GestureEvent* event); 439 440 /** 441 * @brief Obtains the relative offset of a pan gesture along the y-axis. 442 * 443 * @param event Indicates the pointer to the gesture event. 444 * @return Returns the relative offset of the gesture along the y-axis, in px. 445 * @since 12 446 */ 447 float OH_ArkUI_PanGesture_GetOffsetY(const ArkUI_GestureEvent* event); 448 449 /** 450 * @brief Obtains the angle information of the swipe gesture. 451 * 452 * After a swipe gesture is recognized, a line connecting the two fingers is identified as the initial line. 453 * As the fingers swipe, the line between the fingers rotates. \n 454 * Based on the coordinates of the initial line's and current line's end points, the arc tangent function is used to 455 * calculate the respective included angle of the points relative to the horizontal direction \n 456 * by using the following formula: Rotation angle = arctan2(cy2-cy1,cx2-cx1) - arctan2(y2-y1,x2-x1). \n 457 * The initial line is used as the coordinate system. Values from 0 to 180 degrees represent clockwise rotation, 458 * while values from –180 to 0 degrees represent counterclockwise rotation. \n 459 * 460 * @param event Indicates the pointer to the gesture event. 461 * @return Returns the angle of the swipe gesture, which is the result obtained based on the aforementioned formula. 462 * @since 12 463 */ 464 float OH_ArkUI_SwipeGesture_GetAngle(const ArkUI_GestureEvent* event); 465 466 /** 467 * @brief Obtains the average velocity of all fingers used in the swipe gesture. 468 * 469 * @param event Indicates the pointer to the gesture event. 470 * @return Returns the average velocity of all fingers used in the swipe gesture, in px/s. 471 * @since 12 472 */ 473 float OH_ArkUI_SwipeGesture_GetVelocity(const ArkUI_GestureEvent* event); 474 475 /** 476 * @brief Obtains the angle information of a rotation gesture. 477 * 478 * @param event Indicates the pointer to the gesture event. 479 * @return Returns the rotation angle. 480 * @since 12 481 */ 482 float OH_ArkUI_RotationGesture_GetAngle(const ArkUI_GestureEvent* event); 483 484 /** 485 * @brief Obtains the scale ratio of a pinch gesture. 486 * 487 * @param event Indicates the pointer to the gesture event. 488 * @return Returns the scale ratio. 489 * @since 12 490 */ 491 float OH_ArkUI_PinchGesture_GetScale(const ArkUI_GestureEvent* event); 492 493 /** 494 * @brief Obtains the X coordinate of the center of the pinch gesture, in vp, 495 * relative to the upper left corner of the current component. 496 * 497 * @param event Indicates the pointer to the gesture event. 498 * @return Returns the X coordinate of the center of the pinch gesture, in vp, 499 * relative to the upper left corner of the current component. 500 * @since 12 501 */ 502 float OH_ArkUI_PinchGesture_GetCenterX(const ArkUI_GestureEvent* event); 503 504 /** 505 * @brief Obtains the Y coordinate of the center of the pinch gesture, in vp, 506 * relative to the upper left corner of the current component. 507 * 508 * @param event Indicates the pointer to the gesture event. 509 * @return Returns the Y coordinate of the center of the pinch gesture, in vp, 510 * relative to the upper left corner of the current component. 511 * @since 12 512 */ 513 float OH_ArkUI_PinchGesture_GetCenterY(const ArkUI_GestureEvent* event); 514 515 /** 516 * @brief Obtains information about a gesture response chain. 517 * 518 * @param event Indicates the pointer to the gesture interruption information. 519 * @param responseChain Indicates the pointer to an array of gesture recognizers on the response chain. 520 * @param count Indicates the pointer to the number of gesture recognizers on the response chain. 521 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. 522 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. 523 * @since 12 524 */ 525 int32_t OH_ArkUI_GetResponseRecognizersFromInterruptInfo(const ArkUI_GestureInterruptInfo* event, 526 ArkUI_GestureRecognizerHandleArray* responseChain, int32_t* count); 527 528 /** 529 * @brief Sets the enabled state of a gesture recognizer. 530 * 531 * @param recognizer Indicates the pointer to a gesture recognizer. 532 * @param enabled Indicates the enabled state. 533 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. 534 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. 535 * @since 12 536 */ 537 int32_t OH_ArkUI_SetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer, bool enabled); 538 539 /** 540 * @brief Sets whether to enable strict finger count checking. If this feature is enabled and the actual number of touch 541 * fingers does not match the set number, the gesture recognition fails. 542 * 543 * @param recognizer Indicates the pointer to a gesture recognizer. 544 * @param limitFingerCount Indicates whether to enable strict finger count checking. 545 * @return Returns <b>0</b> if the operation is successful. 546 * Returns <b>401</b> if a parameter error occurs. 547 * @since 15 548 */ 549 int32_t OH_ArkUI_SetGestureRecognizerLimitFingerCount(ArkUI_GestureRecognizer* recognizer, bool limitFingerCount); 550 551 552 /** 553 * @brief Obtains the enabled state of a gesture recognizer. 554 * 555 * @param recognizer Indicates the pointer to a gesture recognizer. 556 * @return Returns <b>true</b> if the gesture recognizer is enabled. 557 * Returns <b>false</b> if the gesture recognizer is disabled. 558 * @since 12 559 */ 560 bool OH_ArkUI_GetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer); 561 562 /** 563 * @brief Obtains the state of a gesture recognizer. 564 * 565 * @param recognizer Indicates the pointer to a gesture recognizer. 566 * @param state Indicates the pointer to the state of the gesture recognizer. 567 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. 568 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. 569 * @since 12 570 */ 571 int32_t OH_ArkUI_GetGestureRecognizerState(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureRecognizerState* state); 572 573 /** 574 * @brief Obtains the information about a gesture event target. 575 * 576 * @param recognizer Indicates the pointer to a gesture recognizer. 577 * @param info Indicates the information about a gesture event target. 578 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. 579 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. 580 * @since 12 581 */ 582 int32_t OH_ArkUI_GetGestureEventTargetInfo(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureEventTargetInfo** info); 583 584 /** 585 * @brief Obtains whether this scroll container is scrolled to the top. 586 * 587 * @param info Indicates the information about a gesture event target. 588 * @param ret Indicates whether the scroll container is scrolled to the top. 589 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. 590 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. 591 * Returns {@link ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER} if the component is not a scroll container. 592 * @since 12 593 */ 594 int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollBegin(ArkUI_GestureEventTargetInfo* info, bool* ret); 595 596 /** 597 * @brief Obtains whether this scroll container is scrolled to the bottom. 598 * 599 * @param info Indicates the information about a gesture event target. 600 * @param ret Indicates whether the scroll container is scrolled to the bottom. 601 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. 602 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. 603 * Returns {@link ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER} if the component is not a scroll container. 604 * @since 12 605 */ 606 int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollEnd(ArkUI_GestureEventTargetInfo* info, bool* ret); 607 608 /** 609 * @brief Obtains the direction of a pan gesture. 610 * 611 * @param recognizer Indicates the pointer to a gesture recognizer. 612 * @param directionMask Indicates the pan direction. 613 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. 614 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. 615 * @since 12 616 */ 617 int32_t OH_ArkUI_GetPanGestureDirectionMask(ArkUI_GestureRecognizer* recognizer, 618 ArkUI_GestureDirectionMask* directionMask); 619 620 /** 621 * @brief Obtains whether a gesture is a built-in gesture. 622 * 623 * @param recognizer Indicates the pointer to a gesture recognizer. 624 * @return Returns <b>true</b> if the gesture is a built-in gesture; returns <b>false</b> otherwise. 625 * @since 12 626 */ 627 bool OH_ArkUI_IsBuiltInGesture(ArkUI_GestureRecognizer* recognizer); 628 629 /** 630 * @brief Obtains the tag of a gesture recognizer. 631 * 632 * @param recognizer Indicates the pointer to a gesture recognizer. 633 * @param buffer Indicates the buffer. 634 * @param bufferSize Indicates the buffer size. 635 * @param result Indicates the length of the string to be written to the buffer. 636 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. 637 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. 638 * Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH} if the buffer is not large enough. 639 * @since 12 640 */ 641 int32_t OH_ArkUI_GetGestureTag(ArkUI_GestureRecognizer* recognizer, char* buffer, int32_t bufferSize, int32_t* result); 642 643 /** 644 * @brief Obtains the ID of the component linked to a gesture recognizer. 645 * 646 * @param recognizer Indicates the pointer to a gesture recognizer. 647 * @param nodeId Indicates the component ID. 648 * @param size Indicates the buffer size. 649 * @param result Indicates the length of the string to be written to the buffer. 650 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. 651 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. 652 * Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH} if the buffer is not large enough. 653 * @since 12 654 */ 655 int32_t OH_ArkUI_GetGestureBindNodeId(ArkUI_GestureRecognizer* recognizer, char* nodeId, int32_t size, 656 int32_t* result); 657 658 /** 659 * @brief Obtains whether a gesture recognizer is valid. 660 * 661 * @param recognizer Indicates the pointer to a gesture recognizer. 662 * @return Returns <b>true</b> if the gesture recognizer is valid. 663 * Returns <b>false</b> if the gesture recognizer is invalid. 664 * @since 12 665 */ 666 bool OH_ArkUI_IsGestureRecognizerValid(ArkUI_GestureRecognizer* recognizer); 667 668 /** 669 * @brief Obtains custom data in the parallel internal gesture event. 670 * 671 * @param event Indicates the pointer to a parallel internal gesture event. 672 * @return Returns the pointer to custom data. 673 * @since 12 674 */ 675 void* OH_ArkUI_ParallelInnerGestureEvent_GetUserData(ArkUI_ParallelInnerGestureEvent* event); 676 677 /** 678 * @brief Obtains the current gesture recognizer in a parallel internal gesture event. 679 * 680 * @param event Indicates the pointer to a parallel internal gesture event. 681 * @return Returns the pointer to the current gesture recognizer. 682 * @since 12 683 */ 684 ArkUI_GestureRecognizer* OH_ArkUI_ParallelInnerGestureEvent_GetCurrentRecognizer( 685 ArkUI_ParallelInnerGestureEvent* event); 686 687 /** 688 * @brief Obtains the conflicting gesture recognizers in a parallel internal gesture event. 689 * 690 * @param event Indicates the pointer to a parallel internal gesture event. 691 * @param array Indicates the pointer to the array of conflicting gesture recognizers. 692 * @param size Indicates the size of the array of conflicting gesture recognizers. 693 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. 694 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. 695 * @since 12 696 */ 697 int32_t OH_ArkUI_ParallelInnerGestureEvent_GetConflictRecognizers(ArkUI_ParallelInnerGestureEvent* event, 698 ArkUI_GestureRecognizerHandleArray* array, int32_t* size); 699 700 /** 701 * @brief Sets a callback function for notifying gesture recognizer destruction. 702 * 703 * @param recognizer Indicates the pointer to a gesture recognizer. 704 * @param callback Indicates the callback function for notifying gesture recognizer destruction. 705 * @param userData Indicates the custom data. 706 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. 707 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. 708 */ 709 int32_t OH_ArkUI_SetArkUIGestureRecognizerDisposeNotify(ArkUI_GestureRecognizer* recognizer, 710 ArkUI_GestureRecognizerDisposeNotifyCallback callback, void* userData); 711 712 /** 713 * @brief Obtains the swipe direction of a gesture recognizer. 714 * 715 * @param recognizer Pointer to a gesture recognizer. 716 * @param directMask Swipe direction of the gesture recognizer. 717 * @return Returns the result code. 718 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 719 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 720 * @since 18 721 */ 722 int32_t OH_ArkUI_GetGestureParam_DirectMask( 723 ArkUI_GestureRecognizer* recognizer, ArkUI_GestureDirectionMask* directMask); 724 725 /** 726 * @brief Obtains the number of fingers used by a gesture recognizer. 727 * 728 * @param recognizer Pointer to a gesture recognizer. 729 * @param finger Number of fingers used by the gesture recognizer. 730 * @return Returns the result code. 731 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 732 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 733 * @since 18 734 */ 735 int32_t OH_ArkUI_GetGestureParam_FingerCount(ArkUI_GestureRecognizer* recognizer, int* finger); 736 737 /** 738 * @brief Checks whether a gesture recognizer has a finger count limit. 739 * 740 * @param recognizer Pointer to a gesture recognizer. 741 * @param isLimited Whether the gesture recognizer has a finger count limit. 742 * @return Returns the result code. 743 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 744 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 745 * @since 18 746 */ 747 int32_t OH_ArkUI_GetGestureParam_limitFingerCount(ArkUI_GestureRecognizer* recognizer, bool* isLimited); 748 749 /** 750 * @brief Checks whether a gesture recognizer supports repeated event callbacks. 751 * 752 * @param recognizer Pointer to a gesture recognizer. 753 * @param isRepeat Whether the gesture recognizer supports repeated event callbacks. 754 * @return Returns the result code. 755 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 756 * Returns {@link ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED} if the gesture recognizer type is not 757 * supported. 758 * @since 18 759 */ 760 int32_t OH_ArkUI_GetGestureParam_repeat(ArkUI_GestureRecognizer* recognizer, bool* isRepeat); 761 762 /** 763 * @brief Obtains the allowed movement distance range for a gesture recognizer. 764 * 765 * @param recognizer Pointer to a gesture recognizer. 766 * @param distance Allowed movement distance range of the gesture recognizer. 767 * @return Returns the result code. 768 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 769 * Returns {@link ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED} if the gesture recognizer type is not 770 * supported. 771 * @since 18 772 */ 773 int32_t OH_ArkUI_GetGestureParam_distance(ArkUI_GestureRecognizer* recognizer, double* distance); 774 775 /** 776 * @brief Obtains the minimum swipe speed recognized by a gesture recognizer. 777 * 778 * @param recognizer Pointer to a gesture recognizer. 779 * @param speed Minimum swipe speed recognized by a gesture recognizer. 780 * @return Returns the result code. 781 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 782 * Returns {@link ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED} if the gesture recognizer type is not 783 * supported. 784 * @since 18 785 */ 786 int32_t OH_ArkUI_GetGestureParam_speed(ArkUI_GestureRecognizer* recognizer, double* speed); 787 788 /** 789 * @brief Obtains the minimum duration required to trigger a long press by a gesture recognizer. 790 * 791 * @param recognizer Pointer to a gesture recognizer. 792 * @param duration Minimum duration for a long press. 793 * @return Returns the result code. 794 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 795 * Returns {@link ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED} if the gesture recognizer type is not 796 * supported. 797 * @since 18 798 */ 799 int32_t OH_ArkUI_GetGestureParam_duration(ArkUI_GestureRecognizer* recognizer, int* duration); 800 801 /** 802 * @brief Obtains the minimum angle change required for a rotation gesture to be recognized by a gesture recognizer. 803 * 804 * @param recognizer Pointer to a gesture recognizer. 805 * @param angle Minimum angle change. 806 * @return Returns the result code. 807 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 808 * Returns {@link ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED} if the gesture recognizer type is not 809 * supported. 810 * @since 18 811 */ 812 int32_t OH_ArkUI_GetGestureParam_angle(ArkUI_GestureRecognizer* recognizer, double* angle); 813 814 /** 815 * @brief Obtains the movement threshold for gestures to be recognized by a gesture recognizer. 816 * 817 * @param recognizer Pointer to a gesture recognizer. 818 * @param distanceThreshold Movement threshold. 819 * @return Returns the result code. 820 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 821 * Returns {@link ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED} if the gesture recognizer type is not 822 * supported. 823 * @since 18 824 */ 825 int32_t OH_ArkUI_GetGestureParam_distanceThreshold(ArkUI_GestureRecognizer* recognizer, double* distanceThreshold); 826 827 /** 828 * @brief Sets the minimum movement distance thresholds for gestures to be recognized by a gesture recognizer. 829 * 830 * @param recognizer Indicates the pointer to a gesture recognizer. 831 * @param size Size of the array of minimum movement distance thresholds. 832 * @param toolTypeArray Pointer to the array of tool types for which thresholds are set. 833 * @param distanceArray Pointer to the array of minimum movement distances. 834 * @return Returns the result code. 835 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 836 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 837 * Returns {@link ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED} if the gesture recognizer type is 838 * not supported. 839 * @since 19 840 */ 841 ArkUI_ErrorCode OH_ArkUI_PanGesture_SetDistanceMap( 842 ArkUI_GestureRecognizer* recognizer, int size, int* toolTypeArray, double* distanceArray); 843 844 /** 845 * @brief Registers a callback to be executed after all gesture recognizers have been collected. 846 * When the user begins touching the screen, the system performs hit testing and collects gesture 847 * recognizers based on the touch location. 848 * Subsequently, before processing any move events, the component can use this API to determine 849 * the gesture recognizers that will participate in the recognition and compete with each other. 850 * 851 * @param node Node to set the callback for gesture collection completion. 852 * @param userData Indicates the custom data. 853 * @param recognizerCollected Callback for gesture collection completion. 854 * @return Returns the result code. 855 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 856 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 857 * @since 20 858 */ 859 ArkUI_ErrorCode OH_ArkUI_SetTouchTestDoneCallback( 860 ArkUI_NodeHandle node, 861 void* userData, 862 void (*touchTestDone)( 863 ArkUI_GestureEvent* event, 864 ArkUI_GestureRecognizerHandleArray recognizers, 865 int32_t count, 866 void* userData 867 ) 868 ); 869 870 /** 871 * @brief Prevents a gesture recognizer from participating in the current gesture recognition 872 * before all fingers are lifted. If the system has already determined the result of this gesture 873 * recognizer (whether successful or not), calling this API will have no effect. 874 * 875 * @param recognizer Pointer to the gesture recognizer. 876 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 877 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 878 * @since 20 879 */ 880 ArkUI_ErrorCode OH_ArkUI_PreventGestureRecognizerBegin(ArkUI_GestureRecognizer* recognizer); 881 882 /** 883 * @brief Obtains the movement threshold for gestures to be recognized by a gesture recognizer for a specific tool type. 884 * 885 * @param recognizer Indicates the pointer to a gesture recognizer. 886 * @param toolType Tool type for which you want to obtain the threshold. 887 * @param distance Gesture movement threshold of the gesture recognizer. 888 * @return Returns the result code. 889 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 890 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. 891 * Returns {@link ARKUI_ERROR_CODE_RECOGNIZER_TYPE_NOT_SUPPORTED} if the gesture recognizer type is 892 * not supported. 893 * @since 19 894 */ 895 ArkUI_ErrorCode OH_ArkUI_PanGesture_GetDistanceByToolType( 896 ArkUI_GestureRecognizer* recognizer, int toolType, double* distance); 897 898 ArkUI_NodeHandle OH_ArkUI_GestureEvent_GetNode(const ArkUI_GestureEvent* event); 899 /** 900 * @brief Defines the gesture APIs. 901 * 902 * @since 12 903 */ 904 typedef struct { 905 /** The struct version is 1. */ 906 int32_t version; 907 908 /** 909 * @brief Creates a tap gesture. 910 * 911 * 1. This API is used to trigger a tap gesture with one, two, or more taps. \n 912 * 2. If multi-tap is configured, the timeout interval between a lift and the next tap is 300 ms. \n 913 * 3. If the distance between the last tapped position and the current tapped position exceeds 60 vp, 914 * gesture recognition fails. \n 915 * 4. If the value is greater than 1, the tap gesture will fail to be recognized when the number of fingers 916 * touching the screen within 300 ms of the first finger touch is less than the required number, \n 917 * or when the number of fingers lifted from the screen within 300 ms of the first finger's being lifted 918 * is less than the required number. \n 919 * 5. When the number of fingers touching the screen exceeds the set value, the gesture can be recognized. \n 920 * 921 * @param countNum Indicates the number of consecutive taps. If the value is less than 1 or is not set, 922 * the default value <b>1</b> is used. 923 * @param fingersNum Indicates the number of fingers required to trigger a tap. The value ranges 924 * from 1 to 10. If the value is less than 1 or is not set, the default value <b>1</b> is used. 925 * @return Returns the pointer to the created gesture. 926 */ 927 ArkUI_GestureRecognizer* (*createTapGesture)(int32_t countNum, int32_t fingersNum); 928 929 /** 930 * @brief Creates a long press gesture. 931 * 932 * 1. This API is used to trigger a long press gesture, which requires one or more fingers with a minimum 933 * The value ranges 500 ms hold-down time. \n 934 * 2. In components that support drag actions by default, such as <b><Text></b>, <b><TextInput></b>, 935 * <b><TextArea></b>, <b><Hyperlink></b>, <b><Image></b>, and <b>RichEditor></b>, the long press gesture \n 936 * may conflict with the drag action. If this occurs, they are handled as follows: \n 937 * If the minimum duration of the long press gesture is less than 500 ms, the long press gesture receives 938 * a higher response priority than the drag action. \n 939 * If the minimum duration of the long press gesture is greater than or equal to 500 ms, 940 * the drag action receives a higher response priority than the long press gesture. \n 941 * 3. If a finger moves more than 15 px after being pressed, the gesture recognition fails. \n 942 * 943 * @param fingersNum Indicates the minimum number of fingers to trigger a long press gesture. 944 * The value ranges from 1 to 10. 945 * @param repeatResult Indicates whether to continuously trigger the event callback. 946 * @param durationNum Indicates the minimum hold-down time, in ms. 947 * If the value is less than or equal to 0, the default value <b>500</b> is used. 948 * @return Returns the pointer to the created gesture. 949 */ 950 ArkUI_GestureRecognizer* (*createLongPressGesture)(int32_t fingersNum, bool repeatResult, int32_t durationNum); 951 952 /** 953 * @brief Creates a pan gesture. 954 * 955 * 1. This API is used to trigger a pan gesture when the movement distance of a finger on the screen exceeds 956 * the minimum value. \n 957 * 2. If a pan gesture and a tab swipe occur at the same time, set <b>distanceNum</b> to <b>1</b> 958 * so that the gesture can be more easily recognized. \n 959 * 960 * @param fingersNum Indicates the minimum number of fingers to trigger a pan gesture. The value ranges from 1 to 10. 961 * If the value is less than 1 or is not set, the default value <b>1</b> is used. 962 * @param directions Indicates the pan direction. The value supports the AND (&) and OR (\|) operations. 963 * @param distanceNum Indicates the minimum pan distance to trigger the gesture, in vp. If this parameter is 964 * set to a value less than or equal to 0, the default value <b>5</b> is used. 965 * @return Returns the pointer to the created gesture. 966 */ 967 ArkUI_GestureRecognizer* (*createPanGesture)( 968 int32_t fingersNum, ArkUI_GestureDirectionMask directions, double distanceNum); 969 970 /** 971 * @brief Creates a pinch gesture. 972 * 973 * 1. This API is used to trigger a pinch gesture, which requires two to five fingers with a minimum 5 vp 974 * distance between the fingers. \n 975 * 2. While more fingers than the minimum number can be pressed to trigger the gesture, only the first 976 * fingers of the minimum number participate in gesture calculation. \n 977 * 978 * @param fingersNum Indicates the minimum number of fingers to trigger a pinch. The value ranges from 2 to 5. 979 * Default value: <b>2</b> 980 * @param distanceNum Indicates the minimum recognition distance, in px. If this parameter is set to a value less 981 * than or equal to 0, the default value <b>5</b> is used. 982 * @return Returns the pointer to the created gesture. 983 */ 984 ArkUI_GestureRecognizer* (*createPinchGesture)(int32_t fingersNum, double distanceNum); 985 986 /** 987 * @brief Creates a rotation gesture. 988 * 989 * 1. This API is used to trigger a rotation gesture, which requires two to five fingers with a 990 * minimum 1-degree rotation angle. \n 991 * 2. While more fingers than the minimum number can be pressed to trigger the gesture, only the first 992 * two fingers participate in gesture calculation. \n 993 * 994 * @param fingersNum Indicates the minimum number of fingers to trigger a rotation. The value ranges from 2 to 5. 995 * Default value: <b>2</b> 996 * @param angleNum Indicates the minimum degree that can trigger the rotation gesture. Default value: <b>1</b> 997 * If this parameter is set to a value less than or equal to 0 or greater than 360, 998 * the default value <b>1</b> is used. 999 * @return Returns the pointer to the created gesture. 1000 */ 1001 ArkUI_GestureRecognizer* (*createRotationGesture)(int32_t fingersNum, double angleNum); 1002 1003 /** 1004 * @brief Creates a swipe gesture. 1005 * 1006 * This API is used to implement a swipe gesture, which can be recognized when the swipe speed is 100 1007 * vp/s or higher. \n 1008 * 1009 * @param fingersNum Indicates the minimum number of fingers to trigger a swipe gesture. 1010 * The value ranges from 1 to 10. 1011 * @param directions Indicates the swipe direction. 1012 * @param speedNum Indicates the minimum speed of the swipe gesture, in px/s. 1013 * If this parameter is set to a value less than or equal to 0, the default value <b>100</b> is used. 1014 * @return Returns the pointer to the created gesture. 1015 */ 1016 ArkUI_GestureRecognizer* (*createSwipeGesture)( 1017 int32_t fingersNum, ArkUI_GestureDirectionMask directions, double speedNum); 1018 1019 /** 1020 * @brief Creates a gesture group. 1021 * 1022 * @param gestureMode Indicates the gesture group mode. 1023 * @return Returns the pointer to the created gesture group. 1024 */ 1025 ArkUI_GestureRecognizer* (*createGroupGesture)(ArkUI_GroupGestureMode gestureMode); 1026 1027 /** 1028 * @brief Disposes a gesture to release resources. 1029 * 1030 * @param recognizer Indicates the pointer to the gesture to dispose. 1031 */ 1032 void (*dispose)(ArkUI_GestureRecognizer* recognizer); 1033 1034 /** 1035 * @brief Adds a gesture to a gesture group. 1036 * 1037 * @param group Indicates the pointer to the gesture group. 1038 * @param child Indicates the gesture to be added to the gesture group. 1039 * @return Returns <b>0</b> if success. 1040 * Returns <b>401</b> if a parameter exception occurs. Returns 401 if a parameter exception occurs. 1041 */ 1042 int32_t (*addChildGesture)(ArkUI_GestureRecognizer* group, ArkUI_GestureRecognizer* child); 1043 1044 /** 1045 * @brief Removes a gesture to a gesture group. 1046 * 1047 * @param group Indicates the pointer to the gesture group. 1048 * @param child Indicates the gesture to be removed to the gesture group. 1049 * @return Returns <b>0</b> if success. 1050 * Returns <b>401</b> if a parameter exception occurs. 1051 */ 1052 int32_t (*removeChildGesture)(ArkUI_GestureRecognizer* group, ArkUI_GestureRecognizer* child); 1053 1054 /** 1055 * @brief Registers a callback for gestures. 1056 * 1057 * @param recognizer Indicates the pointer to the gesture recognizer. 1058 * @param actionTypeMask Indicates the set of gesture event types. Multiple callbacks can be registered at once, 1059 * with the callback event types distinguished in the callbacks. 1060 * Example: actionTypeMask = GESTURE_EVENT_ACTION_ACCEPT | GESTURE_EVENT_ACTION_UPDATE; 1061 * @param extraParams Indicates the context passed in the <b>targetReceiver</b> callback. 1062 * @param targetReceiver Indicates the callback to register for processing the gesture event types. 1063 * <b>event</b> indicates the gesture callback data. 1064 * @return Returns <b>0</b> if success. 1065 * Returns <b>401</b> if a parameter exception occurs. 1066 */ 1067 int32_t (*setGestureEventTarget)( 1068 ArkUI_GestureRecognizer* recognizer, ArkUI_GestureEventActionTypeMask actionTypeMask, void* extraParams, 1069 void (*targetReceiver)(ArkUI_GestureEvent* event, void* extraParams)); 1070 1071 /** 1072 * @brief Adds a gesture to a UI component. 1073 * 1074 * @param node Indicates the UI component to which you want to add the gesture. 1075 * @param recognizer Indicates the gesture to be added to the UI component. 1076 * @param mode Indicates the gesture event mode. Available options are <b>NORMAL_GESTURE</b>, 1077 * <b>PARALLEL_GESTURE</b>, and <b>PRIORITY_GESTURE</b>. 1078 * @param mask Indicates the gesture masking mode. 1079 * @return Returns <b>0</b> if success. 1080 * Returns <b>401</b> if a parameter exception occurs. 1081 */ 1082 int32_t (*addGestureToNode)( 1083 ArkUI_NodeHandle node, ArkUI_GestureRecognizer* recognizer, ArkUI_GesturePriority mode, ArkUI_GestureMask mask); 1084 1085 /** 1086 * @brief Removes a gesture from a node. 1087 * 1088 * @param node Indicates the node from which you want to remove the gesture. 1089 * @param recognizer Indicates the gesture to be removed. 1090 * @return Returns <b>0</b> if success. 1091 * Returns <b>401</b> if a parameter exception occurs. 1092 */ 1093 int32_t (*removeGestureFromNode)(ArkUI_NodeHandle node, ArkUI_GestureRecognizer* recognizer); 1094 1095 /** 1096 * @brief Sets a gesture interruption callback for a node. 1097 * 1098 * @param node Indicates the node for which you want to set a gesture interruption callback. 1099 * @param interrupter Indicates the gesture interruption callback to set. 1100 * <b>info</b> indicates the gesture interruption data. If <b>interrupter</b> returns 1101 * <b>GESTURE_INTERRUPT_RESULT_CONTINUE</b>, the gesture recognition process continues. If it returns 1102 * <b>GESTURE_INTERRUPT_RESULT_REJECT</b>, the gesture recognition process is paused. 1103 * @return Returns <b>0</b> if success. 1104 * Returns <b>401</b> if a parameter exception occurs. 1105 */ 1106 int32_t (*setGestureInterrupterToNode)( 1107 ArkUI_NodeHandle node, ArkUI_GestureInterruptResult (*interrupter)(ArkUI_GestureInterruptInfo* info)); 1108 1109 /** 1110 * @brief Obtains the type of a gesture. 1111 * 1112 * @param recognizer Indicates the pointer to the gesture. 1113 * @return Returns the gesture type. 1114 */ 1115 ArkUI_GestureRecognizerType (*getGestureType)(ArkUI_GestureRecognizer* recognizer); 1116 1117 /** 1118 * @brief Sets the callback function for a parallel internal gesture event. 1119 * 1120 * @param node Indicates the ArkUI node for which the callback of a parallel internal gesture event is to be set. 1121 * @param userData Indicates the custom data. 1122 * @param parallelInnerGesture Indicates the parallel internal gesture event. <b>event</b> returns the data of the 1123 * parallel internal gesture event; <b>parallelInnerGesture</b> returns the pointer to the gesture recognizer 1124 * that requires parallel recognition. 1125 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. 1126 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. 1127 */ 1128 int32_t (*setInnerGestureParallelTo)( 1129 ArkUI_NodeHandle node, void* userData, ArkUI_GestureRecognizer* (*parallelInnerGesture)( 1130 ArkUI_ParallelInnerGestureEvent* event)); 1131 1132 /** 1133 * @brief Creates a tap gesture that is subject to distance restrictions. 1134 * 1135 * 1. This API is used to trigger a tap gesture with one, two, or more taps. \n 1136 * 2. If multi-tap is configured, the timeout interval between a lift and the next tap is 300 ms. \n 1137 * 3. If the distance between the last tapped position and the current tapped position exceeds 60 vp, 1138 * gesture recognition fails. \n 1139 * 4. If the value is greater than 1, the tap gesture will fail to be recognized when the number of fingers 1140 * touching the screen within 300 ms of the first finger touch is less than the required number, 1141 * or when the number of fingers lifted from the screen within 300 ms of the first finger's being lifted 1142 * is less than the required number. \n 1143 * 5. When the number of fingers touching the screen exceeds the set value, the gesture can be recognized. \n 1144 * 6. If the finger moves beyond the preset distance limit, gesture recognition fails. \n 1145 * 1146 * @param countNum Indicates the number of consecutive taps. If the value is less than 1 or is not set, the default 1147 * value <b>1</b> is used. 1148 * @param fingersNum Indicates the number of fingers required to trigger a tap. The value ranges from 1 to 10. 1149 * If the value is less than 1 or is not set, the default value <b>1</b> is used. 1150 * @param distanceThreshold Indicates the allowed moving distance of a finger. 1151 * The unit of this parameter is px. 1152 * If the value is less than 0, it will be converted to the default value of infinity. 1153 * @return Returns the pointer to the created gesture. 1154 */ 1155 ArkUI_GestureRecognizer* (*createTapGestureWithDistanceThreshold)( 1156 int32_t countNum, int32_t fingersNum, double distanceThreshold); 1157 } ArkUI_NativeGestureAPI_1; 1158 1159 /** 1160 * @brief Defines the gesture APIs. 1161 * 1162 * @since 18 1163 */ 1164 typedef struct { 1165 /** 1166 * @brief Pointer to the <b>ArkUI_NativeGestureAPI_1</b> struct. 1167 */ 1168 ArkUI_NativeGestureAPI_1* gestureApi1; 1169 1170 /** 1171 * @brief Sets the callback for gesture interruption events. 1172 * 1173 * @param node Node for which you want to set a gesture interruption callback. 1174 * @param userData Custom data. 1175 * @param interrupter Gesture interruption callback to set. <b>info</b> indicates the gesture interruption data. 1176 * If <b>interrupter</b> returns <b>GESTURE_INTERRUPT_RESULT_CONTINUE</b>, the gesture recognition process proceeds 1177 * properly. If it returns <b>GESTURE_INTERRUPT_RESULT_REJECT</b>, the gesture recognition process is paused. 1178 * @return Returns <b>0</b> if success. 1179 * Returns <b>401</b> if a parameter error occurs. 1180 */ 1181 int32_t (*setGestureInterrupterToNode)(ArkUI_NodeHandle node, void* userData, 1182 ArkUI_GestureInterruptResult (*interrupter)(ArkUI_GestureInterruptInfo* info)); 1183 } ArkUI_NativeGestureAPI_2; 1184 1185 /** 1186 * @brief Obtains the custom data from a gesture interruption event. 1187 * 1188 * @param event Pointer to the gesture interruption information. 1189 * @return Returns the pointer to the custom data. 1190 * @since 18 1191 */ 1192 void* OH_ArkUI_GestureInterrupter_GetUserData(ArkUI_GestureInterruptInfo* event); 1193 1194 #ifdef __cplusplus 1195 }; 1196 #endif 1197 1198 #endif // ARKUI_NATIVE_GESTTURE_H 1199 /** @} */