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_EventModule 18 * @{ 19 * 20 * @brief Declares the UI input event capabilities provided by ArkUI on the native side. 21 * 22 * @since 12 23 */ 24 25 /** 26 * @file ui_input_event.h 27 * 28 * @brief Provides ArkUI event definitions on the native side. 29 * 30 * @library libace_ndk.z.so 31 * @syscap SystemCapability.ArkUI.ArkUI.Full 32 * @since 12 33 */ 34 35 #ifndef _ARKUI_UI_INPUT_EVENT_H_ 36 #define _ARKUI_UI_INPUT_EVENT_H_ 37 38 #include "native_type.h" 39 #ifdef __cplusplus 40 #include <cstdint> 41 #else 42 #include <stdint.h> 43 #include <stdbool.h> 44 #endif 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 /** 51 * @brief Defines the UI input event. 52 * 53 * @since 12 54 */ 55 typedef struct ArkUI_UIInputEvent ArkUI_UIInputEvent; 56 57 /** 58 * @brief Enumerates the UI input event types. 59 * 60 * @since 12 61 */ 62 typedef enum { 63 ARKUI_UIINPUTEVENT_TYPE_UNKNOWN = 0, 64 ARKUI_UIINPUTEVENT_TYPE_TOUCH = 1, 65 ARKUI_UIINPUTEVENT_TYPE_AXIS = 2, 66 ARKUI_UIINPUTEVENT_TYPE_MOUSE = 3, 67 ARKUI_UIINPUTEVENT_TYPE_KEY = 4, 68 } ArkUI_UIInputEvent_Type; 69 70 /** 71 * @brief Defines the action code of the input event. 72 * 73 * @since 12 74 */ 75 enum { 76 /** Cancellation of touch. */ 77 UI_TOUCH_EVENT_ACTION_CANCEL = 0, 78 /** Pressing of a touch point. */ 79 UI_TOUCH_EVENT_ACTION_DOWN = 1, 80 /** Moving of a touch point. */ 81 UI_TOUCH_EVENT_ACTION_MOVE = 2, 82 /** Lifting of a touch point. */ 83 UI_TOUCH_EVENT_ACTION_UP = 3, 84 }; 85 86 /** 87 * @brief Defines the tool type of the touch event. 88 * 89 * @since 12 90 */ 91 enum { 92 /** Unknown tool type. */ 93 UI_INPUT_EVENT_TOOL_TYPE_UNKNOWN = 0, 94 95 /** Finger. */ 96 UI_INPUT_EVENT_TOOL_TYPE_FINGER = 1, 97 98 /** Pen. */ 99 UI_INPUT_EVENT_TOOL_TYPE_PEN = 2, 100 101 /** Mouse. */ 102 UI_INPUT_EVENT_TOOL_TYPE_MOUSE = 3, 103 104 /** TouchPad. */ 105 UI_INPUT_EVENT_TOOL_TYPE_TOUCHPAD = 4, 106 107 /** JoyStick. */ 108 UI_INPUT_EVENT_TOOL_TYPE_JOYSTICK = 5, 109 }; 110 111 /** 112 * @brief Defines the source type of the touch event. 113 * 114 * @since 12 115 */ 116 enum { 117 /** Unknown source type. */ 118 UI_INPUT_EVENT_SOURCE_TYPE_UNKNOWN = 0, 119 /** Mouse. */ 120 UI_INPUT_EVENTT_SOURCE_TYPE_MOUSE = 1, 121 /** Touchscreen. */ 122 UI_INPUT_EVENTT_SOURCE_TYPE_TOUCH_SCREEN = 2, 123 }; 124 125 /** 126 * @brief Enumerates the hit test modes. 127 * 128 * @since 12 129 */ 130 typedef enum { 131 /** Both the node and its child node respond to the hit test of a touch event, but its sibling node is blocked from 132 * the hit test. 133 */ 134 HTM_DEFAULT = 0, 135 136 /** The node responds to the hit test of a touch event, but its child node and sibling node are blocked from the hit 137 * test. 138 */ 139 HTM_BLOCK, 140 141 /** Both the node and its child node respond to the hit test of a touch event, and its sibling node is also 142 * considered during the hit test. 143 */ 144 HTM_TRANSPARENT, 145 146 /** The node does not respond to the hit test of a touch event, but its child node and sibling node are considered 147 * during the hit test. 148 */ 149 HTM_NONE, 150 151 /** 152 * Blocks all lower priority siblings and parents node from receiving the event. 153 * @since 20 154 */ 155 HTM_BLOCK_HIERARCHY, 156 157 /** 158 * Self not respond to the hit test for touch events, 159 * and all descendants (children, grandchildren, etc.) not respond to the hit test for touch events too. 160 * @since 20 161 */ 162 HTM_BLOCK_DESCENDANTS, 163 } HitTestMode; 164 165 /** 166 * @brief 定义鼠标事件的Action Code。 167 * 168 * @since 12 169 */ 170 enum { 171 /** 无效行为 */ 172 UI_MOUSE_EVENT_ACTION_UNKNOWN = 0, 173 /** 鼠标按键按下。 */ 174 UI_MOUSE_EVENT_ACTION_PRESS = 1, 175 /** 鼠标按键松开。 */ 176 UI_MOUSE_EVENT_ACTION_RELEASE = 2, 177 /** 鼠标移动。 */ 178 UI_MOUSE_EVENT_ACTION_MOVE = 3, 179 /** 鼠标按键被取消。 */ 180 UI_MOUSE_EVENT_ACTION_CANCEL = 13, 181 }; 182 183 /** 184 * @brief 定义鼠标事件的按键类型。 185 * 186 * @since 12 187 */ 188 enum { 189 /** 无按键。 */ 190 UI_MOUSE_EVENT_BUTTON_NONE = 0, 191 /** 鼠标左键。 */ 192 UI_MOUSE_EVENT_BUTTON_LEFT = 1, 193 /** 鼠标右键。 */ 194 UI_MOUSE_EVENT_BUTTON_RIGHT = 2, 195 /** 鼠标中键。 */ 196 UI_MOUSE_EVENT_BUTTON_MIDDLE = 3, 197 /** 鼠标左侧后退键。 */ 198 UI_MOUSE_EVENT_BUTTON_BACK = 4, 199 /** 鼠标左侧前进键。 */ 200 UI_MOUSE_EVENT_BUTTON_FORWARD = 5, 201 }; 202 203 /** 204 * @brief Defines an enum for modifier keys. 205 * 206 * @since 12 207 */ 208 typedef enum { 209 /** Ctrl. */ 210 ARKUI_MODIFIER_KEY_CTRL = 1 << 0, 211 /** Shift. */ 212 ARKUI_MODIFIER_KEY_SHIFT = 1 << 1, 213 /** Alt. */ 214 ARKUI_MODIFIER_KEY_ALT = 1 << 2, 215 /** Fn. */ 216 ARKUI_MODIFIER_KEY_FN = 1 << 3, 217 } ArkUI_ModifierKeyName; 218 219 /** 220 * @brief Defines an enum for the axis types for focus axis events. 221 * 222 * @since 15 223 */ 224 enum { 225 /** ABS_X. */ 226 UI_FOCUS_AXIS_EVENT_ABS_X = 0, 227 /** ABS_Y. */ 228 UI_FOCUS_AXIS_EVENT_ABS_Y = 1, 229 /** ABS_Z. */ 230 UI_FOCUS_AXIS_EVENT_ABS_Z = 2, 231 /** ABS_RZ. */ 232 UI_FOCUS_AXIS_EVENT_ABS_RZ = 3, 233 /** ABS_GAS. */ 234 UI_FOCUS_AXIS_EVENT_ABS_GAS = 4, 235 /** ABS_BRAKE. */ 236 UI_FOCUS_AXIS_EVENT_ABS_BRAKE = 5, 237 /** ABS_HAT0X. */ 238 UI_FOCUS_AXIS_EVENT_ABS_HAT0X = 6, 239 /** ABS_HAT0Y. */ 240 UI_FOCUS_AXIS_EVENT_ABS_HAT0Y = 7, 241 }; 242 243 /** 244 * @brief Enumerates the action types for axis events. 245 * 246 * @since 15 247 */ 248 enum { 249 /** The axis event is abnormal. */ 250 UI_AXIS_EVENT_ACTION_NONE = 0, 251 /** The axis event begins. */ 252 UI_AXIS_EVENT_ACTION_BEGIN = 1, 253 /** The axis event is updated. */ 254 UI_AXIS_EVENT_ACTION_UPDATE = 2, 255 /** The axis event ends. */ 256 UI_AXIS_EVENT_ACTION_END = 3, 257 /** The axis event is canceled. */ 258 UI_AXIS_EVENT_ACTION_CANCEL = 4, 259 }; 260 261 /** 262 * @brief Defines interaction hand for touch event. 263 * 264 * @since 15 265 */ 266 typedef enum { 267 /** UnKnown. */ 268 ARKUI_EVENT_HAND_NONE = 0, 269 /** Left hand. */ 270 ARKUI_EVENT_HAND_LEFT = 1, 271 /** Right hand. */ 272 ARKUI_EVENT_HAND_RIGHT = 2, 273 } ArkUI_InteractionHand; 274 275 /** 276 * @brief Obtains the type of this UI input event. 277 * 278 * @param event Indicates the pointer to the current UI input event. 279 * @return Returns the type of the current UI input event; returns <b>0</b> if any parameter error occurs. 280 * @since 12 281 */ 282 int32_t OH_ArkUI_UIInputEvent_GetType(const ArkUI_UIInputEvent* event); 283 284 /** 285 * @brief Obtains the action type of this UI input event. 286 * 287 * @param event Indicates the pointer to the current UI input event. 288 * @return Returns the action type of the current UI input event; returns <b>0</b> if any parameter error occurs. 289 * @since 12 290 */ 291 int32_t OH_ArkUI_UIInputEvent_GetAction(const ArkUI_UIInputEvent* event); 292 293 /** 294 * @brief Obtains the source type of this UI input event. 295 * 296 * @param event Indicates the pointer to the current UI input event. 297 * @return Returns the source type of the current UI input event. 298 * @since 12 299 */ 300 int32_t OH_ArkUI_UIInputEvent_GetSourceType(const ArkUI_UIInputEvent* event); 301 302 /** 303 * @brief Obtains the tool type of this UI input event. 304 * 305 * @param event Indicates the pointer to the current UI input event. 306 * @return Returns the tool type of the current UI input event. 307 * @since 12 308 */ 309 int32_t OH_ArkUI_UIInputEvent_GetToolType(const ArkUI_UIInputEvent* event); 310 311 /** 312 * @brief Obtains the time when this UI input event occurs. 313 * 314 * @param event Indicates the pointer to the current UI input event. 315 * @return Returns the time when the UI input event occurs; returns <b>0</b> if any parameter error occurs. 316 * @since 12 317 */ 318 int64_t OH_ArkUI_UIInputEvent_GetEventTime(const ArkUI_UIInputEvent* event); 319 320 /** 321 * @brief Obtains the number of touch points from a directional input event (such as a touch event, mouse event, 322 * or axis event). 323 * 324 * @param event Indicates the pointer to the current UI input event. 325 * @return Returns the number of touch points for the directional input event. 326 * @since 12 327 */ 328 uint32_t OH_ArkUI_PointerEvent_GetPointerCount(const ArkUI_UIInputEvent* event); 329 330 /** 331 * @brief Obtains the ID of a touch point from a directional input event (such as a touch event, mouse event, 332 * or axis event). 333 * 334 * @param event Indicates the pointer to the current UI input event. 335 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 336 * @return Returns the ID of the corresponding touch point. 337 * @since 12 338 */ 339 int32_t OH_ArkUI_PointerEvent_GetPointerId(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 340 341 /** 342 * @brief Obtains the X coordinate relative to the upper left corner of the current component from a directional 343 * input event (such as a touch event, mouse event, or axis event). 344 * 345 * @param event Indicates the pointer to the directional input event. 346 * @return Returns the X coordinate relative to the upper left corner of the current component; 347 * returns <b>0</b> if any parameter error occurs. 348 * @since 12 349 */ 350 float OH_ArkUI_PointerEvent_GetX(const ArkUI_UIInputEvent* event); 351 352 /** 353 * @brief Obtains the X coordinate of a specific touch point relative to the upper left corner of the current component 354 * from a directional input event (such as a touch event, mouse event, or axis event). 355 * 356 * @param event Indicates the pointer to the current UI input event. 357 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 358 * @return Returns the X coordinate relative to the upper left corner of the current component; 359 * returns <b>0.0f</b> if any parameter error occurs. 360 * @since 12 361 */ 362 float OH_ArkUI_PointerEvent_GetXByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 363 364 /** 365 * @brief Obtains the Y coordinate relative to the upper left corner of the current component from a directional 366 * input event (such as a touch event, mouse event, or axis event). 367 * 368 * @param event Indicates the pointer to the UI input event. 369 * @return Returns the Y coordinate relative to the upper left corner of the current component; 370 * returns <b>0</b> if any parameter error occurs. 371 * @since 12 372 */ 373 float OH_ArkUI_PointerEvent_GetY(const ArkUI_UIInputEvent* event); 374 375 /** 376 * @brief Obtains the Y coordinate of a specific touch point relative to the upper left corner of the current component 377 * from a directional input event (such as a touch event, mouse event, or axis event). 378 * 379 * @param event Indicates the pointer to the current UI input event. 380 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 381 * @return Returns the Y coordinate relative to the upper left corner of the current component; 382 * returns <b>0.0f</b> if any parameter error occurs. 383 * @since 12 384 */ 385 float OH_ArkUI_PointerEvent_GetYByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 386 387 /** 388 * @brief Obtains the X coordinate relative to the upper left corner of the current application window from a 389 * directional input event (such as a touch event, mouse event, or axis event). 390 * 391 * @param event Indicates the pointer to the UI input event. 392 * @return Returns the X coordinate relative to the upper left corner of the current application window; 393 * returns <b>0</b> if any parameter error occurs. 394 * @since 12 395 */ 396 float OH_ArkUI_PointerEvent_GetWindowX(const ArkUI_UIInputEvent* event); 397 398 /** 399 * @brief Obtains the X coordinate of a specific touch point relative to the upper left corner of the current 400 * application window from a directional input event (such as a touch event, mouse event, or axis event). 401 * 402 * @param event Indicates the pointer to the current UI input event. 403 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 404 * @return Returns the X coordinate relative to the upper left corner of the current application window; 405 * returns <b>0.0f</b> if any parameter error occurs. 406 * @since 12 407 */ 408 float OH_ArkUI_PointerEvent_GetWindowXByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 409 410 /** 411 * @brief Obtains the Y coordinate relative to the upper left corner of the current application window from a 412 * directional input event (such as a touch event, mouse event, or axis event). 413 * 414 * @param event Indicates the pointer to the UI input event. 415 * @return Returns the Y coordinate relative to the upper left corner of the current application window; 416 * returns <b>0</b> if any parameter error occurs. 417 * @since 12 418 */ 419 float OH_ArkUI_PointerEvent_GetWindowY(const ArkUI_UIInputEvent* event); 420 421 /** 422 * @brief Obtains the Y coordinate of a specific touch point relative to the upper left corner of the current 423 * application window from a directional input event (such as a touch event, mouse event, or axis event). 424 * 425 * @param event Indicates the pointer to the current UI input event. 426 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 427 * @return Returns the Y coordinate relative to the upper left corner of the current application window; 428 * returns <b>0.0f</b> if any parameter error occurs. 429 * @since 12 430 */ 431 float OH_ArkUI_PointerEvent_GetWindowYByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 432 433 /** 434 * @brief Obtains the X coordinate relative to the upper left corner of the current screen from a directional input 435 * event (such as a touch event, mouse event, or axis event). 436 * 437 * @param event Indicates the pointer to the UI input event. 438 * @return Returns the X coordinate relative to the upper left corner of the current screen; 439 * returns <b>0</b> if any parameter error occurs. 440 * @since 12 441 */ 442 float OH_ArkUI_PointerEvent_GetDisplayX(const ArkUI_UIInputEvent* event); 443 444 /** 445 * @brief Obtains the X coordinate of a specific touch point relative to the upper left corner of the current screen 446 * from a directional input event (such as a touch event, mouse event, or axis event). 447 * 448 * @param event Indicates the pointer to the current UI input event. 449 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 450 * @return Returns the X coordinate relative to the upper left corner of the current screen; 451 * returns <b>0.0f</b> if any parameter error occurs. 452 * @since 12 453 */ 454 float OH_ArkUI_PointerEvent_GetDisplayXByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 455 456 /** 457 * @brief Obtains the Y coordinate relative to the upper left corner of the current screen from a directional input 458 * event (such as a touch event, mouse event, or axis event). 459 * 460 * @param event Indicates the pointer to the UI input event. 461 * @return Returns the Y coordinate relative to the upper left corner of the current screen; 462 * returns <b>0</b> if any parameter error occurs. 463 * @since 12 464 */ 465 float OH_ArkUI_PointerEvent_GetDisplayY(const ArkUI_UIInputEvent* event); 466 467 /** 468 * @brief Obtains the Y coordinate of a specific touch point relative to the upper left corner of the current screen 469 * from a directional input event (such as a touch event, mouse event, or axis event). 470 * 471 * @param event Indicates the pointer to the current UI input event. 472 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 473 * @return Returns the Y coordinate relative to the upper left corner of the current screen; 474 * returns <b>0.0f</b> if any parameter error occurs. 475 * @since 12 476 */ 477 float OH_ArkUI_PointerEvent_GetDisplayYByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 478 479 /** 480 * @brief Obtains the X coordinate relative to global display from a pointer event (such as a touch, mouse, 481 * or axis event). 482 * Position information can only be obtained from UI input events. 483 * 484 * @param event Pointer to the current UI input event. 485 * @return float X coordinate relative to the global display. <b>0</b> is returned if any parameter error occurs 486 * (for example, if the event does not contain position information). 487 * @since 20 488 */ 489 float OH_ArkUI_PointerEvent_GetGlobalDisplayX(const ArkUI_UIInputEvent* event); 490 491 /** 492 * @brief Obtains the X coordinate of a specific contact point relative to global display from a pointer event 493 * (such as a touch, mouse, or axis event). 494 * Position information can only be obtained from UI input events. For mouse and axis events, if the provided 495 * <b>pointerIndex</b> is greater than 0, this API always returns the default value <b>0.0f</b>. 496 * 497 * @param event Pointer to the current UI input event. 498 * @param pointerIndex Index of the target touch point in the multi-touch data list. 499 *Value range: [0, @link OH_ArkUI_PointerEvent_GetPointerCount() - 1] 500 * @return float X coordinate relative to the global display; <b>0.0f</b> if any parameter error occurs. 501 * @since 20 502 */ 503 float OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 504 505 /** 506 * @brief Obtains the Y coordinate relative to global display from a pointer event (such as a touch, mouse, 507 * or axis event). 508 * Position information can only be obtained from pointer-like events. 509 * 510 * @param event Pointer to the current UI input event. 511 * @return float Y coordinate relative to the global display; <b>0</b> if any parameter error occurs 512 * (for example, if the event does not contain position information). 513 * @since 20 514 */ 515 float OH_ArkUI_PointerEvent_GetGlobalDisplayY(const ArkUI_UIInputEvent* event); 516 517 /** 518 * @brief Obtains the Y coordinate of a specific contact point relative to global display from a pointer event 519 * (such as a touch, mouse, or axis event). 520 * Position information can only be obtained from UI input events. For mouse and axis events, if the provided 521 * <b>pointerIndex</b> is greater than 0, this API always returns the default value <b>0.0f</b>. 522 * 523 * @param event Pointer to the current UI input event. 524 * @param pointerIndex Index of the target touch point in the multi-touch data list. 525 *Value range: [0, @link OH_ArkUI_PointerEvent_GetPointerCount() - 1] 526 * @return float Y coordinate relative to the global display; <b>0.0f</b> if any parameter error occurs. 527 * @since 20 528 */ 529 float OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 530 531 /** 532 * @brief Obtains the pressure applied to the touchscreen from a directional input event (for example, a touch event). 533 * 534 * @param event Indicates the pointer to the current UI input event. 535 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 536 * @return Returns the pressure applied to the touchscreen; returns <b>0.0f</b> if any parameter error occurs. 537 * @since 12 538 */ 539 float OH_ArkUI_PointerEvent_GetPressure(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 540 541 /** 542 * @brief Obtains the angle relative to the YZ plane from a directional input event (for example, a touch event). 543 * The value range is [-90, 90]. A positive value indicates a rightward tilt. 544 * 545 * @param event Indicates the pointer to the current UI input event. 546 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 547 * @return Returns the angle relative to the YZ plane. 548 * @since 12 549 */ 550 float OH_ArkUI_PointerEvent_GetTiltX(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 551 552 /** 553 * @brief Obtains the angle relative to the XZ plane from a directional input event (for example, a touch event). 554 * The value range is [-90, 90]. A positive value indicates a downward tilt. 555 * 556 * @param event Indicates the pointer to the current UI input event. 557 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 558 * @return Returns the angle relative to the XZ plane. 559 * @since 12 560 */ 561 float OH_ArkUI_PointerEvent_GetTiltY(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 562 563 /** 564 * @brief Obtains the rotation angle of the stylus around the z-axis from a UI input event. 565 * 566 * @param event Pointer to the UI input event. 567 * @param rollAngle Rotation angle of the stylus around the z-axis. 568 * @return Returns the result code. 569 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 570 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 571 * @since 17 572 */ 573 int32_t OH_ArkUI_PointerEvent_GetRollAngle(const ArkUI_UIInputEvent* event, double* rollAngle); 574 575 /** 576 * @brief Obtains the interaction hand of a touch point. 577 * 578 * @param event Indicates the pointer to the current UI input event. 579 * @param hand Indicates the interaction hand of a touch point. 580 * @return Returns the result code. 581 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 582 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. 583 * @since 15 584 */ 585 int32_t OH_ArkUI_PointerEvent_GetInteractionHand(const ArkUI_UIInputEvent *event, ArkUI_InteractionHand *hand); 586 587 /** 588 * @brief Obtains the interaction hand of a touch point. 589 * 590 * @param event Indicates the pointer to the current UI input event. 591 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 592 * @param hand Indicates the interaction hand of a touch point. 593 * @return Returns the result code. 594 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 595 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. 596 * @since 15 597 */ 598 int32_t OH_ArkUI_PointerEvent_GetInteractionHandByIndex( 599 const ArkUI_UIInputEvent *event, int32_t pointerIndex, ArkUI_InteractionHand *hand); 600 601 /** 602 * @brief Obtains the width of the touch area from a directional input event (for example, a touch event). 603 * 604 * @param event Indicates the pointer to the current UI input event. 605 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 606 * @return Returns the width of the touch area. 607 * @since 12 608 */ 609 float OH_ArkUI_PointerEvent_GetTouchAreaWidth(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 610 611 /** 612 * @brief Obtains the height of the touch area from a directional input event (for example, a touch event). 613 * 614 * @param event Indicates the pointer to the current UI input event. 615 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 616 * @return Returns the height of the touch area. 617 * @since 12 618 */ 619 float OH_ArkUI_PointerEvent_GetTouchAreaHeight(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 620 621 /** 622 * @brief Obtains the ID of a touch point which info has been changed. 623 * 624 * @param event Indicates the changed pointer to the current UI input event. 625 * @param pointerIndex Indicates the index of the changed touch point in the multi-touch data list. 626 * @return Returns the result code. 627 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 628 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 629 * @since 15 630 */ 631 int32_t OH_ArkUI_PointerEvent_GetChangedPointerId(const ArkUI_UIInputEvent* event, uint32_t* pointerIndex); 632 633 /** 634 * @brief Obtains the number of historical events from a directional input event (such as a touch event, mouse event, 635 * or axis event). 636 * 637 * @param event Indicates the pointer to the current UI input event. 638 * @return Returns the number of historical events. 639 * @since 12 640 */ 641 uint32_t OH_ArkUI_PointerEvent_GetHistorySize(const ArkUI_UIInputEvent* event); 642 643 /** 644 * @brief Obtains the occurrence time of a historical event from a directional input event (such as a touch event, 645 * mouse event, or axis event). 646 * 647 * @param event Indicates the pointer to the current UI input event. 648 * @param historyIndex Indicates the index of the target historical event. 649 * @return Returns the time when the UI input event occurs; returns <b>0</b> if any parameter error occurs. 650 * @since 12 651 */ 652 int64_t OH_ArkUI_PointerEvent_GetHistoryEventTime(const ArkUI_UIInputEvent* event, uint32_t historyIndex); 653 654 /** 655 * @brief Obtains the number of touch points in a specific historical event from a directional input event (such as 656 * a touch event, mouse event, or axis event). 657 * 658 * @param event Indicates the pointer to the current UI input event. 659 * @param historyIndex Indicates the index of the target historical event. 660 * @return Returns the number of touch points in the specified historical event 661 * @since 12 662 */ 663 uint32_t OH_ArkUI_PointerEvent_GetHistoryPointerCount(const ArkUI_UIInputEvent* event, uint32_t historyIndex); 664 665 /** 666 * @brief Obtains the ID of a touch point in a specific historical event from a directional input event (such as 667 * a touch event, mouse event, or axis event). 668 * 669 * @param event Indicates the pointer to the current UI input event. 670 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 671 * @param historyIndex Indicates the index of the target historical event. 672 * @return Returns the ID of the corresponding touch point in the specified historical event. 673 * @since 12 674 */ 675 int32_t OH_ArkUI_PointerEvent_GetHistoryPointerId( 676 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 677 678 /** 679 * @brief Obtains the X coordinate of a specific touch point in a historical event relative to the upper left corner 680 * of the current component from a directional input event (such as a touch event, mouse event, or axis event). 681 * 682 * @param event Indicates the pointer to the current UI input event. 683 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 684 * @param historyIndex Indicates the index of the target historical event. 685 * @return Returns the X coordinate relative to the upper left corner of the current component; 686 * returns <b>0.0f</b> if any parameter error occurs. 687 * @since 12 688 */ 689 float OH_ArkUI_PointerEvent_GetHistoryX(const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 690 691 /** 692 * @brief Obtains the Y coordinate of a specific touch point in a historical event relative to the upper left corner 693 * of the current component from a directional input event (such as a touch event, mouse event, or axis event). 694 * 695 * @param event Indicates the pointer to the current UI input event. 696 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 697 * @param historyIndex Indicates the index of the target historical event. 698 * @return Returns the Y coordinate relative to the upper left corner of the current component; 699 * returns <b>0.0f</b> if any parameter error occurs. 700 * @since 12 701 */ 702 float OH_ArkUI_PointerEvent_GetHistoryY(const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 703 704 /** 705 * @brief Obtains the X coordinate of a specific touch point in a historical event relative to the upper left corner 706 * of the current application window from a directional input event (such as a touch event, mouse event, or axis event). 707 * 708 * @param event Indicates the pointer to the current UI input event. 709 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 710 * @param historyIndex Indicates the index of the target historical event. 711 * @return Returns the X coordinate relative to the upper left corner of the current application window; 712 * returns <b>0.0f</b> if any parameter error occurs. 713 * @since 12 714 */ 715 float OH_ArkUI_PointerEvent_GetHistoryWindowX( 716 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 717 718 /** 719 * @brief Obtains the Y coordinate of a specific touch point in a historical event relative to the upper left corner 720 * of the current application window from a directional input event (such as a touch event, mouse event, or axis event). 721 * 722 * @param event Indicates the pointer to the current UI input event. 723 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 724 * @param historyIndex Indicates the index of the target historical event. 725 * @return Returns the Y coordinate relative to the upper left corner of the current application window; 726 * returns <b>0.0f</b> if any parameter error occurs. 727 * @since 12 728 */ 729 float OH_ArkUI_PointerEvent_GetHistoryWindowY( 730 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 731 732 /** 733 * @brief Obtains the X coordinate of a specific touch point in a historical event relative to the upper left corner 734 * of the current screen from a directional input event (such as a touch event, mouse event, or axis event). 735 * 736 * @param event Indicates the pointer to the current UI input event. 737 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 738 * @param historyIndex Indicates the index of the target historical event. 739 * @return Returns the X coordinate relative to the upper left corner of the current screen; 740 * returns <b>0.0f</b> if any parameter error occurs. 741 * @since 12 742 */ 743 float OH_ArkUI_PointerEvent_GetHistoryDisplayX( 744 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 745 746 /** 747 * @brief Obtains the Y coordinate of a specific touch point in a historical event relative to the upper left corner 748 * of the current screen from a directional input event (such as a touch event, mouse event, or axis event). 749 * 750 * @param event Indicates the pointer to the current UI input event. 751 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 752 * @param historyIndex Indicates the index of the target historical event. 753 * @return Returns the Y coordinate relative to the upper left corner of the current screen; 754 * returns <b>0.0f</b> if any parameter error occurs. 755 * @since 12 756 */ 757 float OH_ArkUI_PointerEvent_GetHistoryDisplayY( 758 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 759 760 /** 761 * @brief Obtains the X coordinate relative to the global display for a specific touch point from historical events, 762 * based on the given pointer index and history index of an input event (such as a touch, mouse, or axis event). 763 * Position information can only be obtained from UI input events. For mouse and axis events, if the provided 764 * <b>pointerIndex</b> is greater than 0, this API always returns the default value <b>0.0f</b>. 765 * 766 * @param event Pointer to the current UI input event. 767 * @param pointerIndex Index of the target touch point in the multi-touch data list. 768 *Value range: [0, @link OH_ArkUI_PointerEvent_GetPointerCount() - 1] 769 * @param historyIndex Index of the historical value to return. It must be less than 770 * {@link #OH_ArkUI_PointerEvent_GetHistorySize}. 771 * @return float X coordinate relative to the global display; <b>0.0f</b> if any parameter error occurs. 772 * @since 20 773 */ 774 float OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayX( 775 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 776 777 /** 778 * @brief Obtains the Y coordinate relative to the global display for a specific touch point from historical events, 779 * based on the given pointer index and history index of an input event (such as a touch, mouse, or axis event). 780 * Position information can only be obtained from UI input events. For mouse and axis events, if the provided 781 * <b>pointerIndex</b> is greater than 0, this API always returns the default value <b>0.0f</b>. 782 * 783 * @param event Pointer to the current UI input event. 784 * @param pointerIndex Index of the target touch point in the multi-touch data list. 785 *Value range: [0, @link OH_ArkUI_PointerEvent_GetPointerCount() - 1] 786 * @param historyIndex Index of the historical value to return. It must be less than 787 * {@link #OH_ArkUI_PointerEvent_GetHistorySize}. 788 * @return float Y coordinate relative to the global display; <b>0.0f</b> if any parameter error occurs. 789 * @since 20 790 */ 791 float OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayY( 792 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 793 794 /** 795 * @brief Obtains the pressure applied to the touchscreen in a specific historical event from a directional input event 796 * (for example, a touch event).. 797 * 798 * @param event Indicates the pointer to the current UI input event. 799 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 800 * @param historyIndex Indicates the index of the target historical event. 801 * @return Returns the pressure applied to the touchscreen; returns <b>0.0f</b> if any parameter error occurs. 802 * @since 12 803 */ 804 float OH_ArkUI_PointerEvent_GetHistoryPressure( 805 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 806 807 /** 808 * @brief Obtains the angle relative to the YZ plane in a specific historical event from a directional input event 809 * (for example, a touch event). The value range is [-90, 90]. A positive value indicates a rightward tilt. 810 * 811 * @param event Indicates the pointer to the current UI input event. 812 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 813 * @param historyIndex Indicates the index of the target historical event. 814 * @return Returns the angle relative to the YZ plane. 815 * @since 12 816 */ 817 float OH_ArkUI_PointerEvent_GetHistoryTiltX( 818 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 819 820 /** 821 * @brief Obtains the angle relative to the XZ plane in a specific historical event from a directional input event 822 * (for example, a touch event). The value range is [-90, 90]. A positive value indicates a downward tilt. 823 * 824 * @param event Indicates the pointer to the current UI input event. 825 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 826 * @param historyIndex Indicates the index of the target historical event. 827 * @return Returns the angle relative to the XZ plane. 828 * @since 12 829 */ 830 float OH_ArkUI_PointerEvent_GetHistoryTiltY( 831 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 832 833 /** 834 * @brief Obtains the width of the touch area in a specific historical event from a directional input event 835 * (for example, a touch event). 836 * 837 * @param event Indicates the pointer to the current UI input event. 838 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 839 * @param historyIndex Indicates the index of the target historical event. 840 * @return Returns the width of the touch area. 841 * @since 12 842 */ 843 float OH_ArkUI_PointerEvent_GetHistoryTouchAreaWidth( 844 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 845 846 /** 847 * @brief Obtains the height of the touch area in a specific historical event from a directional input event 848 * (for example, a touch event). 849 * 850 * @param event Indicates the pointer to the current UI input event. 851 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 852 * @param historyIndex Indicates the index of the target historical event. 853 * @return Returns the height of the touch area. 854 * @since 12 855 */ 856 float OH_ArkUI_PointerEvent_GetHistoryTouchAreaHeight( 857 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 858 859 /** 860 * @brief Obtains the value of the vertical scroll axis for this axis event. 861 * 862 * @param event Indicates the pointer to the UI input event. 863 * @return Returns the value of the vertical scroll axis of the current axis event; 864 * returns <b>0</b> if any parameter error occurs. 865 * @since 12 866 */ 867 double OH_ArkUI_AxisEvent_GetVerticalAxisValue(const ArkUI_UIInputEvent* event); 868 869 /** 870 * @brief Obtains the value of the horizontal scroll axis for this axis event. 871 * 872 * @param event Indicates the pointer to the UI input event. 873 * @return Returns the value of the horizontal scroll axis of the current axis event; 874 * returns <b>0</b> if any parameter error occurs. 875 * @since 12 876 */ 877 double OH_ArkUI_AxisEvent_GetHorizontalAxisValue(const ArkUI_UIInputEvent* event); 878 879 /** 880 * @brief Obtains the scale value of the pinch axis for this axis event. 881 * 882 * @param event Indicates the pointer to the UI input event. 883 * @return Returns the scale value of the pinch axis of the current axis event; 884 * returns <b>0</b> if any parameter error occurs. 885 * @since 12 886 */ 887 double OH_ArkUI_AxisEvent_GetPinchAxisScaleValue(const ArkUI_UIInputEvent* event); 888 889 /** 890 * @brief Obtains the action type of the current axis event. 891 * 892 * @param event Indicates the pointer to the current UI input event. 893 * @return Returns the action type of the current axis event. 894 * @since 15 895 */ 896 int32_t OH_ArkUI_AxisEvent_GetAxisAction(const ArkUI_UIInputEvent* event); 897 898 /** 899 * @brief Sets how the component behaves during hit testing. 900 * 901 * @param event Indicates the pointer to the current UI input event. 902 * @param mode Indicates how the component behaves during hit testing. The parameter type is {@link HitTestMode}. 903 * @return Returns the status code of the execution. 904 * @since 12 905 */ 906 int32_t OH_ArkUI_PointerEvent_SetInterceptHitTestMode(const ArkUI_UIInputEvent* event, HitTestMode mode); 907 908 /** 909 * @brief 获取鼠标事件的按键类型的值。 910 * 911 * @param event 表示指向当前UI输入事件的指针。 912 * @return 返回鼠标按键类型,1为左键,2为右键,3为中键,4为后退键,5为前进键。 913 * @since 12 914 */ 915 int32_t OH_ArkUI_MouseEvent_GetMouseButton(const ArkUI_UIInputEvent* event); 916 917 /** 918 * @brief 获取鼠标事件的鼠标动作类型的值。 919 * 920 * @param event 表示指向当前UI输入事件的指针。 921 * @return 返回鼠标动作类型,1表示按键按下,2表示按键松开,3表示鼠标移动。 922 * @since 12 923 */ 924 int32_t OH_ArkUI_MouseEvent_GetMouseAction(const ArkUI_UIInputEvent* event); 925 926 /** 927 * @brief Sets whether to prevent event bubbling. 928 * 929 * @param event Indicates the pointer to the current UI input event. 930 * @param stopPropagation Indicates whether the event is prevented from bubbling. 931 * @return Returns the status code of the execution. If 0 is returned, the setting is successful. 932 * If 401 is returned, the execution fails. 933 * The possible cause of the failure is that the event parameter is abnormal, such as a null pointer. 934 * @since 12 935 */ 936 int32_t OH_ArkUI_PointerEvent_SetStopPropagation(const ArkUI_UIInputEvent* event, bool stopPropagation); 937 938 /** 939 * @brief Obtains the ID of device that triggers UI input event. 940 * 941 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 942 * @return Returns the device ID. 943 * @since 14 944 */ 945 int32_t OH_ArkUI_UIInputEvent_GetDeviceId(const ArkUI_UIInputEvent* event); 946 947 /** 948 * @brief Obtains all keys that are pressed from UI input event. Only supports key events currently. 949 * 950 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 951 * @param pressedKeyCodes Array of all keys that are pressed. You need to allocate the memory space. 952 * @param length Length of the passed pressedKeyCodes array (when used as an input parameter); 953 * number of the keys pressed (when used as an output parameter). 954 * @return return Returns the result code. 955 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 956 * Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH} if the giving buffer is not enough. 957 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 958 * @since 14 959 */ 960 int32_t OH_ArkUI_UIInputEvent_GetPressedKeys( 961 const ArkUI_UIInputEvent* event, int32_t* pressedKeyCodes, int32_t* length); 962 963 /** 964 * @brief Obtains the axis value of a focus axis event. 965 * 966 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 967 * @param axis Axis type of the focus axis event. 968 * @return Returns the axis value of the focus axis event; returns <b>0.0</b> if any parameter error occurs. 969 * @since 15 970 */ 971 double OH_ArkUI_FocusAxisEvent_GetAxisValue(const ArkUI_UIInputEvent* event, int32_t axis); 972 973 /** 974 * @brief Sets whether to prevent a focus axis event from bubbling up. 975 * 976 * @param event Indicates the pointer to the current UI input event. 977 * @param stopPropagation Indicates whether to stop event propagation. 978 * @return Returns the result code. 979 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 980 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 981 * @since 15 982 */ 983 int32_t OH_ArkUI_FocusAxisEvent_SetStopPropagation(const ArkUI_UIInputEvent* event, bool stopPropagation); 984 985 /** 986 * @brief Obtains the width of the component hit by an event. 987 * 988 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 989 * @return Returns the width of the component hit by the event; returns <b>0.0f</b> if any parameter error occurs. 990 * @since 17 991 */ 992 float OH_ArkUI_UIInputEvent_GetEventTargetWidth(const ArkUI_UIInputEvent* event); 993 994 /** 995 * @brief Obtains the height of the component hit by an event. 996 * 997 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 998 * @return Returns the height of the component hit by the event; returns <b>0.0f</b> if any parameter error occurs. 999 * @since 17 1000 */ 1001 float OH_ArkUI_UIInputEvent_GetEventTargetHeight(const ArkUI_UIInputEvent* event); 1002 1003 /** 1004 * @brief Obtains the X coordinate of the component hit by an event. 1005 * 1006 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1007 * @return Returns the X coordinate of the component hit by the event; returns <b>0.0f</b> if any parameter error occurs. 1008 * @since 17 1009 */ 1010 float OH_ArkUI_UIInputEvent_GetEventTargetPositionX(const ArkUI_UIInputEvent* event); 1011 1012 /** 1013 * @brief Obtains the Y coordinate of the component hit by an event. 1014 * 1015 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1016 * @return Returns the Y coordinate of the component hit by the event; 1017 * returns <b>0.0f</b> if any parameter error occurs. 1018 * @since 17 1019 */ 1020 float OH_ArkUI_UIInputEvent_GetEventTargetPositionY(const ArkUI_UIInputEvent* event); 1021 1022 /** 1023 * @brief Obtains the global X coordinate of the component hit by an event. 1024 * 1025 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1026 * @return Returns the global X coordinate of the component hit by the event; 1027 * returns <b>0.0f</b> if any parameter error occurs. 1028 * @since 17 1029 */ 1030 float OH_ArkUI_UIInputEvent_GetEventTargetGlobalPositionX(const ArkUI_UIInputEvent* event); 1031 1032 /** 1033 * @brief Obtains the global Y coordinate of the component hit by an event. 1034 * 1035 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1036 * @return Returns the global Y coordinate of the component hit by the event; 1037 * returns <b>0.0f</b> if any parameter error occurs. 1038 * @since 17 1039 */ 1040 float OH_ArkUI_UIInputEvent_GetEventTargetGlobalPositionY(const ArkUI_UIInputEvent* event); 1041 1042 /** 1043 * @brief Checks whether the cursor is hovering over this component. 1044 * 1045 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1046 * @return Returns <b>true</b> if the cursor is hovering over the current component. 1047 * Returns <b>false</b> if the cursor is not hovering over the current component. 1048 * @since 17 1049 */ 1050 bool OH_ArkUI_HoverEvent_IsHovered(const ArkUI_UIInputEvent* event); 1051 1052 /** 1053 * @brief Obtains the state of the modifier keys in a UI input event. 1054 * 1055 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1056 * @param keys Pointer to a variable where the current combination of pressed modifier keys will be returned. 1057 * The application can use bitwise operations to determine the state of each modifier key. 1058 * @return Returns the result code. 1059 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1060 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1061 * @since 17 1062 */ 1063 int32_t OH_ArkUI_UIInputEvent_GetModifierKeyStates(const ArkUI_UIInputEvent* event, uint64_t* keys); 1064 1065 /** 1066 * @brief Obtains the pressed time of a specific touch point. 1067 * 1068 * @param event Indicates the pointer to the current UI input event. 1069 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 1070 * @return Returns the pressed time of a specific touch point; returns <b>0</b> if any parameter error occurs. 1071 * @since 15 1072 */ 1073 int64_t OH_ArkUI_PointerEvent_GetPressedTimeByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 1074 1075 /** 1076 * @brief Obtains the X axis offset relative to the previous reported mouse pointer position. When the mouse pointer is 1077 * at the edge of the screen, the value may be less than the difference of the X coordinate reported twice. 1078 * 1079 * @param event Indicates the pointer to the current UI input event. 1080 * @return Returns the X axis offset relative to the previous reported mouse pointer position; 1081 * returns <b>0.0f</b> if any parameter error occurs. 1082 * @since 15 1083 */ 1084 float OH_ArkUI_MouseEvent_GetRawDeltaX(const ArkUI_UIInputEvent* event); 1085 1086 /** 1087 * @brief Obtains the Y axis offset relative to the previous reported mouse pointer position. When the mouse pointer is 1088 * at the edge of the screen, the value may be less than the difference of the Y coordinate reported twice. 1089 * 1090 * @param event Indicates the pointer to the current UI input event. 1091 * @return Returns the Y axis offset relative to the previous reported mouse pointer position; 1092 * returns <b>0.0f</b> if any parameter error occurs. 1093 * @since 15 1094 */ 1095 float OH_ArkUI_MouseEvent_GetRawDeltaY(const ArkUI_UIInputEvent* event); 1096 1097 /** 1098 * @brief Obtains the pressed buttons from the mouse event. 1099 * 1100 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1101 * @param pressedButtons Indicates the list of the pressed buttons.You need to create a int array first. 1102 * @param length Length of the passed pressedButtons array (when used as an input parameter); 1103 * number of the buttons pressed (when used as an output parameter). 1104 * @return Returns the result code. 1105 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1106 * Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR} if the giving buffer is not enough. 1107 * @since 15 1108 */ 1109 int32_t OH_ArkUI_MouseEvent_GetPressedButtons( 1110 const ArkUI_UIInputEvent* event, int32_t* pressedButtons, int32_t* length); 1111 1112 /** 1113 * @brief Obtains the screen ID on which the UI input event occurred. 1114 * 1115 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1116 * @return Returns the screen ID; returns <b>0</b> if any parameter error occurs. 1117 * @since 15 1118 */ 1119 int32_t OH_ArkUI_UIInputEvent_GetTargetDisplayId(const ArkUI_UIInputEvent* event); 1120 1121 /** 1122 * @brief Sets whether to enable axis event propagation. 1123 * 1124 * @param event Pointer to the UI input event. 1125 * @param propagation Whether to enable event propagation. 1126 * @return Returns the result code. 1127 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1128 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1129 * @since 17 1130 */ 1131 int32_t OH_ArkUI_AxisEvent_SetPropagation(const ArkUI_UIInputEvent* event, bool propagation); 1132 1133 /** 1134 * @brief Obtains the scroll step configuration of the mouse wheel axis event. 1135 * 1136 * @param event Pointer to the UI input event. 1137 * @return Returns the scroll step configuration of the mouse wheel axis event. 1138 * @since 17 1139 */ 1140 int32_t OH_ArkUI_AxisEvent_GetScrollStep(const ArkUI_UIInputEvent* event); 1141 1142 /** 1143 * @brief Create cloned pointer event from the original pointer event. 1144 * 1145 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1146 * @param clonedEvent Pointer to an <b>ArkUI_UIInputEvent</b> pointer. 1147 * @return Returns the result code. 1148 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1149 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1150 * @since 15 1151 */ 1152 int32_t OH_ArkUI_PointerEvent_CreateClonedEvent(const ArkUI_UIInputEvent* event, ArkUI_UIInputEvent** clonedEvent); 1153 1154 /** 1155 * @brief Destroy the cloned pointer event. 1156 * 1157 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1158 * @return Returns the result code. 1159 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1160 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1161 * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the event is not the cloned pointer event. 1162 * @since 15 1163 */ 1164 int32_t OH_ArkUI_PointerEvent_DestroyClonedEvent(const ArkUI_UIInputEvent* event); 1165 1166 /** 1167 * @brief Set the position relative to the upper left corner of the current component from a cloned directional 1168 * input event. 1169 * 1170 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1171 * @param x The X coordinate relative to the upper left corner of the current component, in px. 1172 * @param y The Y coordinate relative to the upper left corner of the current component, in px. 1173 * @return Returns the result code. 1174 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1175 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1176 * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the event is not the cloned pointer event. 1177 * @since 15 1178 */ 1179 int32_t OH_ArkUI_PointerEvent_SetClonedEventLocalPosition(const ArkUI_UIInputEvent* event, float x, float y); 1180 1181 /** 1182 * @brief Set the position of a specific touch point relative to the upper left corner of the current component 1183 * from a cloned directional input event. 1184 * 1185 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1186 * @param x The X coordinate relative to the upper left corner of the current component, in px. 1187 * @param y The Y coordinate relative to the upper left corner of the current component, in px. 1188 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 1189 * @return Returns the result code. 1190 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1191 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1192 * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the event is not the cloned pointer event. 1193 * @since 15 1194 */ 1195 int32_t OH_ArkUI_PointerEvent_SetClonedEventLocalPositionByIndex( 1196 const ArkUI_UIInputEvent* event, float x, float y, int32_t pointerIndex); 1197 1198 /** 1199 * @brief Set the action type of the cloned pointer event. 1200 * 1201 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1202 * @param actionType The action type of pointer event. 1203 * @return Returns the result code. 1204 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1205 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1206 * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the event is not the cloned pointer event. 1207 * @since 15 1208 */ 1209 int32_t OH_ArkUI_PointerEvent_SetClonedEventActionType(const ArkUI_UIInputEvent* event, int32_t actionType); 1210 1211 /** 1212 * @brief Set the ID of the touch point that triggers the current cloned pointer event. 1213 * 1214 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1215 * @param fingerId The ID of the touch point that triggers the current pointer event. 1216 * @return Returns the result code. 1217 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1218 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1219 * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the event is not the cloned pointer event. 1220 * @since 15 1221 */ 1222 int32_t OH_ArkUI_PointerEvent_SetClonedEventChangedFingerId(const ArkUI_UIInputEvent* event, int32_t fingerId); 1223 1224 /** 1225 * @brief Set the ID of a touch point from a cloned directional input event. 1226 * 1227 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1228 * @param fingerId The ID of the touch point. 1229 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 1230 * @return Returns the result code. 1231 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1232 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1233 * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the event is not the cloned pointer event. 1234 * @since 15 1235 */ 1236 int32_t OH_ArkUI_PointerEvent_SetClonedEventFingerIdByIndex( 1237 const ArkUI_UIInputEvent* event, int32_t fingerId, int32_t pointerIndex); 1238 1239 /** 1240 * @brief Post a cloned event to a specific node. 1241 * 1242 * @param node Target node. 1243 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1244 * @return Returns the result code. 1245 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1246 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1247 * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the event is not the cloned pointer event. 1248 * Returns {@link ARKUI_ERROR_CODE_POST_CLONED_COMPONENT_STATUS_ABNORMAL } 1249 * if the component status abnormal. 1250 * Returns {@link ARKUI_ERROR_CODE_POST_CLONED_NO_COMPONENT_HIT_TO_RESPOND_TO_THE_EVENT } 1251 * if no component hit to respond to the event. 1252 * @since 15 1253 */ 1254 int32_t OH_ArkUI_PointerEvent_PostClonedEvent(ArkUI_NodeHandle node, const ArkUI_UIInputEvent* event); 1255 1256 /** 1257 * @brief Obtains the result code of the most recent API call related to an <b>ArkUI_UIInputEvent</b> object. 1258 * This API is typically unnecessary for normal operations, but can be used to verify ambiguous return values 1259 * (for example, when <b>0.0</b> might be either a valid float result or an error). 1260 * float x = OH_ArkUI_PointerEvent_GetX(event); 1261 * if (ARKUI_ERROR_CODE_NO_ERROR != OH_Arkui_UIInputEvent_GetlatestStatus()) { 1262 * // error 1263 * return; 1264 * } 1265 * The system automatically clears the previous status before each API call related to an <b>ArkUI_UIInputEvent</b> 1266 * object, ensuring that this API always returns the latest execution status. 1267 * 1268 * @return Result code of the most recent API call related to the <b>ArkUI_UIInputEvent</b> object. 1269 * @since 20 1270 */ 1271 ArkUI_ErrorCode OH_ArkUI_UIInputEvent_GetLatestStatus(); 1272 1273 #ifdef __cplusplus 1274 }; 1275 #endif 1276 1277 #endif // _ARKUI_UI_INPUT_EVENT_H_ 1278 /** @} */ 1279