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 * @kit ArkUI 33 * @since 12 34 */ 35 36 #ifndef _ARKUI_UI_INPUT_EVENT_H_ 37 #define _ARKUI_UI_INPUT_EVENT_H_ 38 39 #include <stdint.h> 40 41 #include "native_type.h" 42 #ifdef __cplusplus 43 extern "C" { 44 #endif 45 46 /** 47 * @brief Defines the UI input event. 48 * 49 * @since 12 50 */ 51 typedef struct ArkUI_UIInputEvent ArkUI_UIInputEvent; 52 53 /** 54 * @brief Enumerates the UI input event types. 55 * 56 * @since 12 57 */ 58 typedef enum { 59 ARKUI_UIINPUTEVENT_TYPE_UNKNOWN = 0, 60 ARKUI_UIINPUTEVENT_TYPE_TOUCH = 1, 61 ARKUI_UIINPUTEVENT_TYPE_AXIS = 2, 62 /** Mouse event. */ 63 ARKUI_UIINPUTEVENT_TYPE_MOUSE = 3, 64 /** 65 * @brief key event. 66 * 67 * @since 20 68 */ 69 ARKUI_UIINPUTEVENT_TYPE_KEY = 4, 70 } ArkUI_UIInputEvent_Type; 71 72 /** 73 * @brief Defines the action code of the input event. 74 * 75 * @since 12 76 */ 77 enum { 78 /** Cancellation of touch. */ 79 UI_TOUCH_EVENT_ACTION_CANCEL = 0, 80 /** Pressing of a touch point. */ 81 UI_TOUCH_EVENT_ACTION_DOWN = 1, 82 /** Moving of a touch point. */ 83 UI_TOUCH_EVENT_ACTION_MOVE = 2, 84 /** Lifting of a touch point. */ 85 UI_TOUCH_EVENT_ACTION_UP = 3, 86 }; 87 88 /** 89 * @brief Defines the tool type of the touch event. 90 * 91 * @since 12 92 */ 93 enum { 94 /** Unknown tool type. */ 95 UI_INPUT_EVENT_TOOL_TYPE_UNKNOWN = 0, 96 97 /** Finger. */ 98 UI_INPUT_EVENT_TOOL_TYPE_FINGER = 1, 99 100 /** Pen. */ 101 UI_INPUT_EVENT_TOOL_TYPE_PEN = 2, 102 103 /** Mouse. */ 104 UI_INPUT_EVENT_TOOL_TYPE_MOUSE = 3, 105 106 /** TouchPad. */ 107 UI_INPUT_EVENT_TOOL_TYPE_TOUCHPAD = 4, 108 109 /** JoyStick. */ 110 UI_INPUT_EVENT_TOOL_TYPE_JOYSTICK = 5, 111 }; 112 113 /** 114 * @brief Defines the source type of the touch event. 115 * 116 * @since 12 117 */ 118 enum { 119 /** Unknown source type. */ 120 UI_INPUT_EVENT_SOURCE_TYPE_UNKNOWN = 0, 121 /** Mouse. */ 122 UI_INPUT_EVENT_SOURCE_TYPE_MOUSE = 1, 123 /** Touchscreen. */ 124 UI_INPUT_EVENT_SOURCE_TYPE_TOUCH_SCREEN = 2, 125 }; 126 127 /** 128 * @brief Enumerates the hit test modes. 129 * 130 * @since 12 131 */ 132 typedef enum { 133 /** Both the node and its child node respond to the hit test of a touch event, but its sibling node is blocked from 134 * the hit test. 135 */ 136 HTM_DEFAULT = 0, 137 138 /** The node responds to the hit test of a touch event, but its child node and sibling node are blocked from the hit 139 * test. 140 */ 141 HTM_BLOCK, 142 143 /** Both the node and its child node respond to the hit test of a touch event, and its sibling node is also 144 * considered during the hit test. 145 */ 146 HTM_TRANSPARENT, 147 148 /** The node does not respond to the hit test of a touch event, but its child node and sibling node are considered 149 * during the hit test. 150 */ 151 HTM_NONE, 152 153 /** 154 * The node and its child nodes participate in hit tests, while blocking hit tests for all sibling nodes and parent 155 * nodes with lower priority. 156 * 157 * @since 20 158 */ 159 HTM_BLOCK_HIERARCHY, 160 161 /** 162 * The node does not respond to hit tests, and none of its descendants (including children and grandchildren) 163 * participate in hit tests either. 164 * 165 * @since 20 166 */ 167 HTM_BLOCK_DESCENDANTS, 168 } HitTestMode; 169 170 /** 171 * @brief Define the Action Code for mouse events. 172 * 173 * @since 12 174 */ 175 enum { 176 /** Invalid. */ 177 UI_MOUSE_EVENT_ACTION_UNKNOWN = 0, 178 /** Press. */ 179 UI_MOUSE_EVENT_ACTION_PRESS = 1, 180 /** Release. */ 181 UI_MOUSE_EVENT_ACTION_RELEASE = 2, 182 /** Move. */ 183 UI_MOUSE_EVENT_ACTION_MOVE = 3, 184 /** Cancel. 185 * @since 18 186 */ 187 UI_MOUSE_EVENT_ACTION_CANCEL = 13, 188 }; 189 190 /** 191 * @brief Define the button type for mouse events. 192 * 193 * @since 12 194 */ 195 enum { 196 /** None. */ 197 UI_MOUSE_EVENT_BUTTON_NONE = 0, 198 /** Left. */ 199 UI_MOUSE_EVENT_BUTTON_LEFT = 1, 200 /** Right. */ 201 UI_MOUSE_EVENT_BUTTON_RIGHT = 2, 202 /** Middle. */ 203 UI_MOUSE_EVENT_BUTTON_MIDDLE = 3, 204 /** Back. */ 205 UI_MOUSE_EVENT_BUTTON_BACK = 4, 206 /** Forward. */ 207 UI_MOUSE_EVENT_BUTTON_FORWARD = 5, 208 }; 209 210 /** 211 * @brief Defines an enum for modifier keys. 212 * 213 * @since 12 214 */ 215 typedef enum { 216 /** Ctrl. */ 217 ARKUI_MODIFIER_KEY_CTRL = 1 << 0, 218 /** Shift. */ 219 ARKUI_MODIFIER_KEY_SHIFT = 1 << 1, 220 /** Alt. */ 221 ARKUI_MODIFIER_KEY_ALT = 1 << 2, 222 /** Fn. */ 223 ARKUI_MODIFIER_KEY_FN = 1 << 3, 224 } ArkUI_ModifierKeyName; 225 226 /** 227 * @brief Defines an enum for the axis types for focus axis events. 228 * 229 * @since 15 230 */ 231 enum { 232 /** ABS_X. */ 233 UI_FOCUS_AXIS_EVENT_ABS_X = 0, 234 /** ABS_Y. */ 235 UI_FOCUS_AXIS_EVENT_ABS_Y = 1, 236 /** ABS_Z. */ 237 UI_FOCUS_AXIS_EVENT_ABS_Z = 2, 238 /** ABS_RZ. */ 239 UI_FOCUS_AXIS_EVENT_ABS_RZ = 3, 240 /** ABS_GAS. */ 241 UI_FOCUS_AXIS_EVENT_ABS_GAS = 4, 242 /** ABS_BRAKE. */ 243 UI_FOCUS_AXIS_EVENT_ABS_BRAKE = 5, 244 /** ABS_HAT0X. */ 245 UI_FOCUS_AXIS_EVENT_ABS_HAT0X = 6, 246 /** ABS_HAT0Y. */ 247 UI_FOCUS_AXIS_EVENT_ABS_HAT0Y = 7, 248 }; 249 250 /** 251 * @brief Defines whether the touch event is from the left or right hand. 252 * 253 * @since 15 254 */ 255 typedef enum { 256 /** Unknown. */ 257 ARKUI_EVENT_HAND_NONE = 0, 258 /** Left hand. */ 259 ARKUI_EVENT_HAND_LEFT = 1, 260 /** Right hand. */ 261 ARKUI_EVENT_HAND_RIGHT = 2, 262 } ArkUI_InteractionHand; 263 264 /** 265 * @brief Enumerates the action types for axis events. 266 * 267 * @since 15 268 */ 269 enum { 270 /** The axis event is abnormal. */ 271 UI_AXIS_EVENT_ACTION_NONE = 0, 272 /** The axis event begins. */ 273 UI_AXIS_EVENT_ACTION_BEGIN = 1, 274 /** The axis event is updated. */ 275 UI_AXIS_EVENT_ACTION_UPDATE = 2, 276 /** The axis event ends. */ 277 UI_AXIS_EVENT_ACTION_END = 3, 278 /** The axis event is canceled. */ 279 UI_AXIS_EVENT_ACTION_CANCEL = 4, 280 }; 281 282 /** 283 * @brief Obtains the type of a UI input event. 284 * 285 * Before accessing an <b>ArkUI_UIInputEvent</b> pointer, use this API to determine the type of the input event. 286 * This API returns a value from the {@link ArkUI_UIInputEvent_Type} enum. It helps ensure compatibility with subsequent 287 * accessors. For example, if the event is a touch event, 288 * which is directional, you can use OH_ArkUI_UIInputEvent_GetXXX or OH_ArkUI_PointerEvent_GetXXX for access. 289 * Using OH_ArkUI_KeyEvent_GetXXX to access the event may produce undefined behavior. 290 * 291 * For unsupported event types, this API returns the default value <b>0</b>. 292 * 293 * @param event Pointer to the current UI input event. 294 * @return Returns the type of the current UI input event; returns <b>0</b> if any parameter error occurs. 295 * @since 12 296 */ 297 int32_t OH_ArkUI_UIInputEvent_GetType(const ArkUI_UIInputEvent* event); 298 299 /** 300 * @brief Obtains the action type of this UI input event. 301 * 302 * The action type defines the phase of a basic event (for example, start or end) and characterizes its behavior, 303 * such as touch down or touch up Action types are specific to the event category: 304 * UI_TOUCH_EVENT_ACTION_XXX for touch events and UI_MOUSE_EVENT_ACTION_XXX for mouse events. 305 * 306 * @note 307 * 1. For axis events, use {@link OH_ArkUI_AxisEvent_GetAxisAction} to obtain the action type, 308 * which returns UI_AXIS_EVENT_ACTION_XXX. 309 * 2. For key events, use {@link OH_ArkUI_KeyEvent_GetType} instead. 310 * 311 * @param event Pointer to the current UI input event. 312 * @return Returns the action type of the current UI input event; returns <b>-1</b> if any parameter error occurs. 313 * @since 12 314 */ 315 int32_t OH_ArkUI_UIInputEvent_GetAction(const ArkUI_UIInputEvent* event); 316 317 /** 318 * @brief Obtains the source type of a UI input event. 319 * 320 * The source represents the physical device, such as a touchscreen or mouse device, that generates the event. 321 * It is defined by the UI_INPUT_EVENT_SOURCE_TYPE_XXX enum. 322 * This is different from the input tool, which is the device used to interact with the source, for example, 323 * a finger or stylus. However, in certain cases, the input source and the input tool can be the same. 324 * For example, a mouse device acts as both the source and tool for click events. 325 * 326 * @note For key events, obtaining the source type is not supported, and in such cases, 327 * the API will return an <b>unknown</b> value. 328 * 329 * @param event Pointer to the current UI input event. 330 * @return Returns the source type of the current UI input event. 331 * @since 12 332 */ 333 int32_t OH_ArkUI_UIInputEvent_GetSourceType(const ArkUI_UIInputEvent* event); 334 335 /** 336 * @brief Obtains the tool type of a UI input event. 337 * 338 * The input tool is the device used to interact with the input source, such as a finger or stylus. 339 * It is defined by the UI_INPUT_EVENT_TOOL_TYPE_XXX enum. 340 * These tools do not produce events directly but drive the input source to generate them. 341 * 342 * @note For key events, obtaining the tool type is not supported, and in such cases, 343 * the API will return an <b>unknown</b> value. 344 * 345 * @param event Pointer to the current UI input event. 346 * @return Returns the tool type of the current UI input event. 347 * @since 12 348 */ 349 int32_t OH_ArkUI_UIInputEvent_GetToolType(const ArkUI_UIInputEvent* event); 350 351 /** 352 * @brief Obtains the time when this UI input event occurs. 353 * 354 * @param event Indicates the pointer to the current UI input event. 355 * @return Returns the time when the UI input event occurs; returns <b>0</b> if any parameter error occurs. 356 * @since 12 357 */ 358 int64_t OH_ArkUI_UIInputEvent_GetEventTime(const ArkUI_UIInputEvent* event); 359 360 /** 361 * @brief Obtains the number of contact points from a pointer event (such as a touch, mouse, or axis event). 362 * 363 * Pointer events are typically events that carry position information, such as touch events, 364 * where the location of the event can be determined. 365 * Non-pointer events, such as key events, do not have position information and do not involve contact points, 366 * so this API is not applicable to key events. 367 * 368 * For touch events, this API returns the number of active touch points, for example, fingers on the screen. 369 * For mouse and axis events, this API always returns <b>1</b>, as they are single-pointer interactions. 370 * 371 * @param event Pointer to the current UI input event. 372 * @return Number of contact points for the current pointer event. 373 * @since 12 374 */ 375 uint32_t OH_ArkUI_PointerEvent_GetPointerCount(const ArkUI_UIInputEvent* event); 376 377 /** 378 * @brief Obtains the unique ID of a contact point from a pointer event (such as a touch, mouse, or axis event). 379 * 380 * The ID distinguishes between multiple contact points from the same input device. The return value itself does not 381 * have any other meaning beyond identifying the contact point. 382 * 383 * @param event Pointer to the current UI input event. 384 * @param pointerIndex Index of the target contact point in the contact point list. 385 * @return Unique ID of the specified contact point. 386 * @since 12 387 */ 388 int32_t OH_ArkUI_PointerEvent_GetPointerId(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 389 390 /** 391 * @brief Obtains the ID of the touch pointer that triggers the current touch event. 392 * 393 * @param event Indicates the pointer to the current UI input event. 394 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 395 * @return Returns the result code. 396 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 397 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 398 * @since 15 399 */ 400 int32_t OH_ArkUI_PointerEvent_GetChangedPointerId(const ArkUI_UIInputEvent* event, uint32_t* pointerIndex); 401 402 /** 403 * @brief Obtains the X coordinate relative to the upper left corner of the current component from a directional 404 * input event (such as a touch event, mouse event, or axis event). 405 * 406 * @param event Indicates the pointer to the directional input event. 407 * @return Returns the X coordinate relative to the upper left corner of the current component; 408 * returns <b>0</b> if any parameter error occurs. 409 * @since 12 410 */ 411 float OH_ArkUI_PointerEvent_GetX(const ArkUI_UIInputEvent* event); 412 413 /** 414 * @brief Obtains the X coordinate of a specific contact point relative to the upper left corner of the current 415 * component from a pointer event (such as a touch, mouse, or axis event). 416 * For mouse and axis events, this API returns the default value of <b>0.0f</b> if the given index is greater than 0. 417 * 418 * @param event Pointer to the current UI input event. 419 * @param pointerIndex Index of the target contact point in the contact point list. 420 * @return Returns the X coordinate relative to the upper left corner of the current component; 421 * returns <b>0.0f</b> if any parameter error occurs. 422 * @since 12 423 */ 424 float OH_ArkUI_PointerEvent_GetXByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 425 426 /** 427 * @brief Obtains the Y coordinate relative to the upper left corner of the current component from a directional 428 * input event (such as a touch event, mouse event, or axis event). 429 * 430 * @param event Indicates the pointer to the UI input event. 431 * @return Returns the Y coordinate relative to the upper left corner of the current component; 432 * returns <b>0.0f</b> if any parameter error occurs. 433 * @since 12 434 */ 435 float OH_ArkUI_PointerEvent_GetY(const ArkUI_UIInputEvent* event); 436 437 /** 438 * @brief Obtains the Y coordinate of a specific contact point relative to the upper left corner of the current 439 * component from a pointer event (such as a touch, mouse, or axis event). 440 * For mouse and axis events, this API returns the default value of <b>0.0f</b> if the given index is greater than 0. 441 * 442 * @param event Pointer to the current UI input event. 443 * @param pointerIndex Index of the target contact point in the contact point list. 444 * @return Y coordinate relative to the upper left corner of the current component; 445 * <b>0.0f</b> if any parameter error occurs. 446 * @since 12 447 */ 448 float OH_ArkUI_PointerEvent_GetYByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 449 450 /** 451 * @brief Obtains the X coordinate relative to the upper left corner of the current application window from a 452 * directional input event (such as a touch event, mouse event, or axis event). 453 * 454 * @param event Indicates the pointer to the UI input event. 455 * @return Returns the X coordinate relative to the upper left corner of the current application window; 456 * returns <b>0.0f</b> if any parameter error occurs. 457 * @since 12 458 */ 459 float OH_ArkUI_PointerEvent_GetWindowX(const ArkUI_UIInputEvent* event); 460 461 /** 462 * @brief Obtains the X coordinate of a specific contact point relative to the upper left corner of the current 463 * application window from a pointer event (such as a touch, mouse, or axis event). 464 * For mouse and axis events, this API returns the default value of <b>0.0f</b> if the given index is greater than 0. 465 * 466 * @param event Pointer to the current UI input event. 467 * @param pointerIndex Index of the target contact point in the contact point list. 468 * @return X coordinate relative to the upper left corner of the current application window; 469 * <b>0.0f</b> if any parameter error occurs. 470 * @since 12 471 */ 472 float OH_ArkUI_PointerEvent_GetWindowXByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 473 474 /** 475 * @brief Obtains the Y coordinate relative to the upper left corner of the current application window from a 476 * directional input event (such as a touch event, mouse event, or axis event). 477 * 478 * @param event Indicates the pointer to the UI input event. 479 * @return Returns the Y coordinate relative to the upper left corner of the current application window; 480 * returns <b>0.0f</b> if any parameter error occurs. 481 * @since 12 482 */ 483 float OH_ArkUI_PointerEvent_GetWindowY(const ArkUI_UIInputEvent* event); 484 485 /** 486 * @brief Obtains the Y coordinate of a specific contact point relative to the upper left corner of the current 487 * application window from a pointer event (such as a touch, mouse, or axis event). 488 * For mouse and axis events, this API returns the default value of <b>0.0f</b> if the given index is greater than 0. 489 * 490 * @param event Pointer to the current UI input event. 491 * @param pointerIndex Index of the target contact point in the contact point list. 492 * @return Returns the Y coordinate relative to the upper left corner of the current application window; 493 * returns <b>0.0f</b> if any parameter error occurs. 494 * @since 12 495 */ 496 float OH_ArkUI_PointerEvent_GetWindowYByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 497 498 /** 499 * @brief Obtains the X coordinate relative to the upper left corner of the current screen from a directional input 500 * event (such as a touch event, mouse event, or axis event). 501 * 502 * @param event Indicates the pointer to the UI input event. 503 * @return Returns the X coordinate relative to the upper left corner of the current screen; 504 * returns <b>0.0f</b> if any parameter error occurs. 505 * @since 12 506 */ 507 float OH_ArkUI_PointerEvent_GetDisplayX(const ArkUI_UIInputEvent* event); 508 509 /** 510 * @brief Obtains the X coordinate of a specific contact point relative to the upper left corner of the current screen 511 * from a pointer event (such as a touch, mouse, or axis event). 512 * For mouse and axis events, this API returns the default value of <b>0.0f</b> if the given index is greater than 0. 513 * 514 * @param event Pointer to the current UI input event. 515 * @param pointerIndex Index of the target contact point in the contact point list. 516 * @return Returns the X coordinate relative to the upper left corner of the current screen; 517 * returns <b>0.0f</b> if any parameter error occurs. 518 * @since 12 519 */ 520 float OH_ArkUI_PointerEvent_GetDisplayXByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 521 522 /** 523 * @brief Obtains the Y coordinate relative to the upper left corner of the current screen from a directional input 524 * event (such as a touch event, mouse event, or axis event). 525 * 526 * @param event Indicates the pointer to the UI input event. 527 * @return Returns the Y coordinate relative to the upper left corner of the current screen; 528 * returns <b>0.0f</b> if any parameter error occurs. 529 * @since 12 530 */ 531 float OH_ArkUI_PointerEvent_GetDisplayY(const ArkUI_UIInputEvent* event); 532 533 /** 534 * @brief Obtains the Y coordinate of a specific touch point relative to the upper left corner of the current screen 535 * from a pointer event (such as a touch event, mouse event, or axis event). 536 * 537 * @param event Pointer to the current UI input event. 538 * @param pointerIndex Index of the target contact point in the contact point list. 539 * @return Returns the Y coordinate relative to the upper left corner of the current screen; 540 * returns <b>0.0f</b> if any parameter error occurs. 541 * @since 12 542 */ 543 float OH_ArkUI_PointerEvent_GetDisplayYByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 544 545 /** 546 * @brief Obtains the X coordinate relative to global display from a pointer event (such as a touch, mouse, 547 * or axis event). 548 * Position information can only be obtained from UI input events. 549 * 550 * @param event Pointer to the current UI input event. 551 * @return float X coordinate relative to the global display. <b>0</b> is returned if any parameter error occurs 552 * (for example, if the event does not contain position information). 553 * @since 20 554 */ 555 float OH_ArkUI_PointerEvent_GetGlobalDisplayX(const ArkUI_UIInputEvent* event); 556 557 /** 558 * @brief Obtains the X coordinate of a specific contact point relative to global display from a pointer event 559 * (such as a touch, mouse, or axis event). 560 * Position information can only be obtained from UI input events. For mouse and axis events, if the provided 561 * <b>pointerIndex</b> is greater than 0, this API always returns the default value <b>0.0f</b>. 562 * 563 * @param event Pointer to the current UI input event. 564 * @param pointerIndex Index of the target touch point in the multi-touch data list. 565 *Value range: [0, @link OH_ArkUI_PointerEvent_GetPointerCount() - 1] 566 * @return float X coordinate relative to the global display; <b>0.0f</b> if any parameter error occurs. 567 * @since 20 568 */ 569 float OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 570 571 /** 572 * @brief Obtains the Y coordinate relative to global display from a pointer event (such as a touch, mouse, 573 * or axis event). 574 * Position information can only be obtained from pointer-like events. 575 * 576 * @param event Pointer to the current UI input event. 577 * @return float Y coordinate relative to the global display; <b>0</b> if any parameter error occurs 578 * (for example, if the event does not contain position information). 579 * @since 20 580 */ 581 float OH_ArkUI_PointerEvent_GetGlobalDisplayY(const ArkUI_UIInputEvent* event); 582 583 /** 584 * @brief Obtains the Y coordinate of a specific contact point relative to global display from a pointer event 585 * (such as a touch, mouse, or axis event). 586 * Position information can only be obtained from UI input events. For mouse and axis events, if the provided 587 * <b>pointerIndex</b> is greater than 0, this API always returns the default value <b>0.0f</b>. 588 * 589 * @param event Pointer to the current UI input event. 590 * @param pointerIndex Index of the target touch point in the multi-touch data list. 591 *Value range: [0, @link OH_ArkUI_PointerEvent_GetPointerCount() - 1] 592 * @return float Y coordinate relative to the global display; <b>0.0f</b> if any parameter error occurs. 593 * @since 20 594 */ 595 float OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 596 597 /** 598 * @brief Obtains the pressure applied to the touchscreen from a directional input event (for example, a touch event). 599 * 600 * @param event Indicates the pointer to the current UI input event. 601 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 602 * @return Returns the pressure applied to the touchscreen; returns <b>0.0f</b> if any parameter error occurs. 603 * @since 12 604 */ 605 float OH_ArkUI_PointerEvent_GetPressure(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 606 607 /** 608 * @brief Obtains the tilt angle relative to the YZ plane from a pointer event. 609 * The value range is [-90, 90], where positive values indicate a rightward tilt. 610 * This API is applicable only to stylus-based touch events from devices that support tilt angle reporting. 611 * 612 * @param event Pointer to the current UI input event. 613 * @param pointerIndex Index of the target contact point in the contact point list. 614 * @return Returns the angle relative to the YZ plane. 615 * @since 12 616 */ 617 float OH_ArkUI_PointerEvent_GetTiltX(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 618 619 /** 620 * @brief Obtains the tilt angle relative to the XZ plane from a pointer event. 621 * The value range is [-90, 90], where positive values indicate a rightward tilt. 622 * This API is applicable only to stylus-based touch events from devices that support tilt angle reporting. 623 * 624 * @param event Pointer to the current UI input event. 625 * @param pointerIndex Index of the target contact point in the contact point list. 626 * @return Returns the angle relative to the XZ plane. 627 * @since 12 628 */ 629 float OH_ArkUI_PointerEvent_GetTiltY(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 630 631 /** 632 * @brief Obtains the rotation angle of the stylus around the z-axis from a UI input event. 633 * 634 * @param event Pointer to the UI input event. 635 * @param rollAngle Rotation angle of the stylus around the z-axis. 636 * @return Returns the result code. 637 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 638 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 639 * @since 17 640 */ 641 int32_t OH_ArkUI_PointerEvent_GetRollAngle(const ArkUI_UIInputEvent* event, double* rollAngle); 642 643 /** 644 * @brief Obtains the width of the contact area for a pointer event. This API is applicable only to finger-based touch 645 * events, and the return value typically represents the radius of a circular touch area. 646 * 647 * @param event Pointer to the current UI input event. 648 * @param pointerIndex Index of the target contact point in the contact point list. 649 * @return Returns the width of the touch area. 650 * @since 12 651 */ 652 float OH_ArkUI_PointerEvent_GetTouchAreaWidth(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 653 654 /** 655 * @brief Obtains the height of the contact area for a pointer event. This API is applicable only to finger-based touch 656 * events, and the return value typically represents the radius of a circular touch area. 657 * 658 * @param event Pointer to the current UI input event. 659 * @param pointerIndex Index of the target contact point in the contact point list. 660 * @return Returns the height of the touch area. 661 * @since 12 662 */ 663 float OH_ArkUI_PointerEvent_GetTouchAreaHeight(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 664 665 /** 666 * @brief Checks whether an event is triggered by the user's left or right hand. 667 * This API is only effective on some touch devices. 668 * 669 * @note This value cannot be obtained in real time when pressed. Before the 670 * system completes result inference, it will return <b>NONE</b> by default. Therefore, 671 * please do not over-rely on the results returned by this interface. 672 * 673 * @param event Pointer to the current UI input event. 674 * @param hand Whether the touch point is from the left or right hand. 675 * @return Result code. 676 * {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 677 * {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 678 * @since 15 679 */ 680 int32_t OH_ArkUI_PointerEvent_GetInteractionHand(const ArkUI_UIInputEvent *event, ArkUI_InteractionHand *hand); 681 682 /** 683 * @brief Checks whether an event is triggered by the user's left or right hand. 684 * This API is only effective on some touch devices. 685 * 686 * @note This value cannot be obtained in real time when pressed. Before the 687 * system completes result inference, it will return <b>NONE</b> by default. Therefore, 688 * please do not over-rely on the results returned by this interface. 689 * 690 * @param event Pointer to the current UI input event. 691 * @param pointerIndex Index of the target touch point in the multi-touch data list. 692 * @param hand Whether the touch point is from the left or right hand. 693 * @return Result code. 694 * {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 695 * {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 696 * @since 15 697 */ 698 int32_t OH_ArkUI_PointerEvent_GetInteractionHandByIndex( 699 const ArkUI_UIInputEvent *event, int32_t pointerIndex, ArkUI_InteractionHand *hand); 700 701 /** 702 * @brief Obtains the number of historical events from a pointer event (such as a touch event). 703 * Historical events are the raw events that occur between the current event and the previous event. 704 * This API is applicable only to move events. 705 * 706 * @param event Pointer to the current UI input event. 707 * @return Returns the number of historical events. 708 * @since 12 709 */ 710 uint32_t OH_ArkUI_PointerEvent_GetHistorySize(const ArkUI_UIInputEvent* event); 711 712 /** 713 * @brief Obtains the occurrence time of a historical event from a directional input event (such as a touch event, 714 * mouse event, or axis event). 715 * 716 * @param event Indicates the pointer to the current UI input event. 717 * @param historyIndex Indicates the index of the target historical event. 718 * @return Returns the time when the UI input event occurs; returns <b>0</b> if any parameter error occurs. 719 * @since 12 720 */ 721 int64_t OH_ArkUI_PointerEvent_GetHistoryEventTime(const ArkUI_UIInputEvent* event, uint32_t historyIndex); 722 723 /** 724 * @brief Obtains the number of touch points in a specific historical event from a directional input event (such as 725 * a touch event, mouse event, or axis event). 726 * 727 * @param event Indicates the pointer to the current UI input event. 728 * @param historyIndex Indicates the index of the target historical event. 729 * @return Returns the number of touch points in the specified historical event 730 * @since 12 731 */ 732 uint32_t OH_ArkUI_PointerEvent_GetHistoryPointerCount(const ArkUI_UIInputEvent* event, uint32_t historyIndex); 733 734 /** 735 * @brief Obtains the unique ID of a contact point from a historical event of a pointer event (such as a touch event). 736 * 737 * The ID distinguishes between multiple contact points from the same input device. 738 * The return value itself does not have any other meaning beyond identifying the contact point. 739 * 740 * @param event Pointer to the current UI input event. 741 * @param pointerIndex Index of the target contact point in the contact point list. 742 * @param historyIndex Index of the target historical event. 743 * @return Returns the ID of the corresponding touch point in the specified historical event. 744 * @since 12 745 */ 746 int32_t OH_ArkUI_PointerEvent_GetHistoryPointerId( 747 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 748 749 /** 750 * @brief Obtains the X coordinate of a specific touch point in a historical event relative to the upper left corner 751 * of the current component from a directional input event (such as a touch event, mouse event, or axis event). 752 * 753 * @param event Indicates the pointer to the current UI input event. 754 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 755 * @param historyIndex Indicates the index of the target historical event. 756 * @return Returns the X coordinate relative to the upper left corner of the current component; 757 * returns <b>0.0f</b> if any parameter error occurs. 758 * @since 12 759 */ 760 float OH_ArkUI_PointerEvent_GetHistoryX(const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 761 762 /** 763 * @brief Obtains the Y coordinate of a specific touch point in a historical event relative to the upper left corner 764 * of the current component from a directional input event (such as a touch event, mouse event, or axis event). 765 * 766 * @param event Indicates the pointer to the current UI input event. 767 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 768 * @param historyIndex Indicates the index of the target historical event. 769 * @return Returns the Y coordinate relative to the upper left corner of the current component; 770 * returns <b>0.0f</b> if any parameter error occurs. 771 * @since 12 772 */ 773 float OH_ArkUI_PointerEvent_GetHistoryY(const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 774 775 /** 776 * @brief Obtains the X coordinate of a specific touch point in a historical event relative to the upper left corner 777 * of the current application window from a directional input event (such as a touch event, mouse event, or axis event). 778 * 779 * @param event Indicates the pointer to the current UI input event. 780 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 781 * @param historyIndex Indicates the index of the target historical event. 782 * @return Returns the X coordinate relative to the upper left corner of the current application window; 783 * returns <b>0.0f</b> if any parameter error occurs. 784 * @since 12 785 */ 786 float OH_ArkUI_PointerEvent_GetHistoryWindowX( 787 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 788 789 /** 790 * @brief Obtains the Y coordinate of a specific touch point in a historical event relative to the upper left corner 791 * of the current application window from a directional input event (such as a touch event, mouse event, or axis event). 792 * 793 * @param event Indicates the pointer to the current UI input event. 794 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 795 * @param historyIndex Indicates the index of the target historical event. 796 * @return Returns the Y coordinate relative to the upper left corner of the current application window; 797 * returns <b>0.0f</b> if any parameter error occurs. 798 * @since 12 799 */ 800 float OH_ArkUI_PointerEvent_GetHistoryWindowY( 801 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 802 803 /** 804 * @brief Obtains the X coordinate of a specific touch point in a historical event relative to the upper left corner 805 * of the current screen from a directional input event (such as a touch event, mouse event, or axis event). 806 * 807 * @param event Indicates the pointer to the current UI input event. 808 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 809 * @param historyIndex Indicates the index of the target historical event. 810 * @return Returns the X coordinate relative to the upper left corner of the current screen; 811 * returns <b>0.0f</b> if any parameter error occurs. 812 * @since 12 813 */ 814 float OH_ArkUI_PointerEvent_GetHistoryDisplayX( 815 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 816 817 /** 818 * @brief Obtains the Y coordinate of a specific touch point in a historical event relative to the upper left corner 819 * of the current screen from a directional input event (such as a touch event, mouse event, or axis event). 820 * 821 * @param event Indicates the pointer to the current UI input event. 822 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 823 * @param historyIndex Indicates the index of the target historical event. 824 * @return Returns the Y coordinate relative to the upper left corner of the current screen; 825 * returns <b>0.0f</b> if any parameter error occurs. 826 * @since 12 827 */ 828 float OH_ArkUI_PointerEvent_GetHistoryDisplayY( 829 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 830 831 /** 832 * @brief Obtains the X coordinate relative to the global display for a specific touch point from historical events, 833 * based on the given pointer index and history index of an input event (such as a touch, mouse, or axis event). 834 * Position information can only be obtained from UI input events. For mouse and axis events, if the provided 835 * <b>pointerIndex</b> is greater than 0, this API always returns the default value <b>0.0f</b>. 836 * 837 * @param event Pointer to the current UI input event. 838 * @param pointerIndex Index of the target touch point in the multi-touch data list. 839 *Value range: [0, @link OH_ArkUI_PointerEvent_GetPointerCount() - 1] 840 * @param historyIndex Index of the historical value to return. It must be less than 841 * {@link #OH_ArkUI_PointerEvent_GetHistorySize}. 842 * @return float X coordinate relative to the global display; <b>0.0f</b> if any parameter error occurs. 843 * @since 20 844 */ 845 float OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayX( 846 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 847 848 /** 849 * @brief Obtains the Y coordinate relative to the global display for a specific touch point from historical events, 850 * based on the given pointer index and history index of an input event (such as a touch, mouse, or axis event). 851 * Position information can only be obtained from UI input events. For mouse and axis events, if the provided 852 * <b>pointerIndex</b> is greater than 0, this API always returns the default value <b>0.0f</b>. 853 * 854 * @param event Pointer to the current UI input event. 855 * @param pointerIndex Index of the target touch point in the multi-touch data list. 856 *Value range: [0, @link OH_ArkUI_PointerEvent_GetPointerCount() - 1] 857 * @param historyIndex Index of the historical value to return. It must be less than 858 * {@link #OH_ArkUI_PointerEvent_GetHistorySize}. 859 * @return float Y coordinate relative to the global display; <b>0.0f</b> if any parameter error occurs. 860 * @since 20 861 */ 862 float OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayY( 863 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 864 865 /** 866 * @brief Obtains the pressure applied to the touchscreen in a specific historical event from a directional input event 867 * (for example, a touch event).. 868 * 869 * @param event Indicates the pointer to the current UI input event. 870 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 871 * @param historyIndex Indicates the index of the target historical event. 872 * @return Returns the pressure applied to the touchscreen; returns <b>0.0f</b> if any parameter error occurs. 873 * @since 12 874 */ 875 float OH_ArkUI_PointerEvent_GetHistoryPressure( 876 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 877 878 /** 879 * @brief Obtains the angle relative to the YZ plane in a specific historical event from a directional input event 880 * (for example, a touch event). The value range is [-90, 90]. A positive value indicates a rightward tilt. 881 * 882 * @param event Indicates the pointer to the current UI input event. 883 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 884 * @param historyIndex Indicates the index of the target historical event. 885 * @return Returns the angle relative to the YZ plane. 886 * @since 12 887 */ 888 float OH_ArkUI_PointerEvent_GetHistoryTiltX( 889 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 890 891 /** 892 * @brief Obtains the angle relative to the XZ plane in a specific historical event from a directional input event 893 * (for example, a touch event). The value range is [-90, 90]. A positive value indicates a downward tilt. 894 * 895 * @param event Indicates the pointer to the current UI input event. 896 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 897 * @param historyIndex Indicates the index of the target historical event. 898 * @return Returns the angle relative to the XZ plane. 899 * @since 12 900 */ 901 float OH_ArkUI_PointerEvent_GetHistoryTiltY( 902 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 903 904 /** 905 * @brief Obtains the width of the touch area in a specific historical event from a directional input event 906 * (for example, a touch event). 907 * 908 * @param event Indicates the pointer to the current UI input event. 909 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 910 * @param historyIndex Indicates the index of the target historical event. 911 * @return Returns the width of the touch area. 912 * @since 12 913 */ 914 float OH_ArkUI_PointerEvent_GetHistoryTouchAreaWidth( 915 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 916 917 /** 918 * @brief Obtains the height of the touch area in a specific historical event from a directional input event 919 * (for example, a touch event). 920 * 921 * @param event Indicates the pointer to the current UI input event. 922 * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. 923 * @param historyIndex Indicates the index of the target historical event. 924 * @return Returns the height of the touch area. 925 * @since 12 926 */ 927 float OH_ArkUI_PointerEvent_GetHistoryTouchAreaHeight( 928 const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); 929 930 /** 931 * @brief Obtains the value of the vertical scroll axis for this axis event. 932 * This value is typically generated by mouse wheel scrolling or two-finger vertical swiping on a touchpad. 933 * 934 * If the value is generated by mouse wheel scrolling: 935 * 1. The reported value is in degrees and represents the incremental angle of a single scroll, 936 * not the total scroll amount. 937 * 2. The reported value includes the user's scroll step configuration (see {@link OH_ArkUI_AxisEvent_GetScrollStep}). 938 * 3. The sign of the value indicates the direction: positive for forward scrolling and negative for backward scrolling. 939 * 940 * If the value is generated by two-finger vertical swiping on a touchpad: 941 * 1. The reported value is in px and represents the incremental scroll amount, not the total scroll amount. 942 * 2. The reported value does not include the user's scroll step configuration. 943 * 3. The sign of the value indicates the direction: positive for swiping down and negative for swiping up. 944 * 4. The direction is affected by the system settings for natural scrolling. 945 * 946 * Under normal circumstances, vertical scroll axis events only drive vertical swipe gestures. However, 947 * if the mouse pointer is over a scrollable area where the scrollable directions are consistent, 948 * the vertical scroll axis event can drive the swipe gestures in this scrollable area, even if they are defined 949 * as horizontal. 950 * 951 * @param event Pointer to the current UI input event. 952 * @return Value of the vertical scroll axis of the current axis event; <b>0.0</b> if any parameter error occurs. 953 * @since 12 954 */ 955 double OH_ArkUI_AxisEvent_GetVerticalAxisValue(const ArkUI_UIInputEvent* event); 956 957 /** 958 * @brief Obtains the value of the horizontal scroll axis for this axis event. 959 * This value is generated by two-finger horizontal swiping on a touchpad. 960 * 961 * @note 962 * 1. The reported value is in px and represents the incremental scroll amount, not the total scroll amount. 963 * 2. The reported value does not include the user's scroll step configuration. 964 * 3. The sign of the value indicates the direction: positive for swiping right and negative for swiping left. 965 * 4. The direction is affected by the system settings for natural scrolling. 966 * 967 * @param event Pointer to the current UI input event. 968 * @return Returns the value of the horizontal scroll axis of the current axis event; 969 * returns <b>0</b> if any parameter error occurs. 970 * @since 12 971 */ 972 double OH_ArkUI_AxisEvent_GetHorizontalAxisValue(const ArkUI_UIInputEvent* event); 973 974 /** 975 * This value is generated by a two-finger pinch gesture on a touchpad. 976 * The reported scale value is relative to the initial state 977 * 978 * when the system first detects the pinch gesture, with an initial scale value of 1.0. 979 * During the pinch operation, the scale value decreases from 1.0 towards 0.0 when the user pinches inward 980 * and increases from 1.0 when the user spreads fingers outward. 981 * 982 * @param event Pointer to the current UI input event. 983 * @return Scale value of the pinch axis of the current axis event; <b>0.0</b> if any parameter error occurs. 984 * @since 12 985 */ 986 double OH_ArkUI_AxisEvent_GetPinchAxisScaleValue(const ArkUI_UIInputEvent* event); 987 988 /** 989 * @brief Obtains the action type of the current axis event. 990 * 991 * @param event Indicates the pointer to the current UI input event. 992 * @return Returns the action type of the current axis event. 993 * @since 15 994 */ 995 int32_t OH_ArkUI_AxisEvent_GetAxisAction(const ArkUI_UIInputEvent* event); 996 997 /** 998 * @brief Sets the hit testing mode, that is, how the component behaves during hit testing. 999 * This API only applies to scenarios raw input events are received, such as when {@link NODE_ON_TOUCH} is used for 1000 * touch event handling. 1001 * It cannot be used with <b>ArkUI_UIInputEvent</b> objects obtained from gesture events through 1002 * {@link OH_ArkUI_GestureEvent_GetRawInputEvent}. 1003 * 1004 * @param event Pointer to the current UI input event. 1005 * @param mode Hit testing mode, of type {@link HitTestMode}. 1006 * @return Result code. 1007 * @since 12 1008 */ 1009 int32_t OH_ArkUI_PointerEvent_SetInterceptHitTestMode(const ArkUI_UIInputEvent* event, HitTestMode mode); 1010 1011 /** 1012 * @brief Get the value of the button type for mouse events. 1013 * 1014 * @param event Represents a pointer to the current UI input event. 1015 * @return Return to the mouse button type, where <b>1</b> is the left button, <b>2</b> is the right button, 1016 * <b>3</b> is the middle button, <b>4</b> is the back button, and <b>5</b> is the forward button. 1017 * @since 12 1018 */ 1019 int32_t OH_ArkUI_MouseEvent_GetMouseButton(const ArkUI_UIInputEvent* event); 1020 1021 /** 1022 * @brief Get the value of the mouse action type for mouse events. 1023 * 1024 * @param event Represents a pointer to the current UI input event. 1025 * @return Returns the type of mouse action, where <b>1</b> represents button pressed, 1026 * <b>2</b> represents button released, and <b>3</b> represents mouse movement. 1027 * @since 12 1028 */ 1029 int32_t OH_ArkUI_MouseEvent_GetMouseAction(const ArkUI_UIInputEvent* event); 1030 1031 /** 1032 * @brief Sets whether to stop event propagation. This API only applies to scenarios raw input events are received, 1033 * such as when {@link NODE_ON_TOUCH} is used for touch event handling. 1034 * It cannot be used with <b>ArkUI_UIInputEvent</b> objects obtained from gesture events 1035 * through {@link OH_ArkUI_GestureEvent_GetRawInputEvent}. 1036 * 1037 * @param event Pointer to the current UI input event. 1038 * @param stopPropagation Whether to stop event propagation. 1039 * @return Returns the status code of the execution. If 0 is returned, the setting is successful. 1040 * If 401 is returned, the execution fails. 1041 * The possible cause of the failure is that the event parameter is abnormal, such as a null pointer. 1042 * @since 12 1043 */ 1044 int32_t OH_ArkUI_PointerEvent_SetStopPropagation(const ArkUI_UIInputEvent* event, bool stopPropagation); 1045 1046 /** 1047 * @brief Obtains the ID of device that triggers UI input event. 1048 * 1049 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1050 * @return Returns the device ID. 1051 * @since 14 1052 */ 1053 int32_t OH_ArkUI_UIInputEvent_GetDeviceId(const ArkUI_UIInputEvent* event); 1054 1055 /** 1056 * @brief Obtains all keys that are pressed from UI input event. Only supports key events currently. 1057 * 1058 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1059 * @param pressedKeyCodes Array of all keys that are pressed. You need to allocate the memory space. 1060 * @param length Length of the passed pressedKeyCodes array (when used as an input parameter); 1061 * number of the keys pressed (when used as an output parameter). 1062 * @return Returns the result code. 1063 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1064 * Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH} if the giving buffer is not enough. 1065 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1066 * @since 14 1067 */ 1068 int32_t OH_ArkUI_UIInputEvent_GetPressedKeys( 1069 const ArkUI_UIInputEvent* event, int32_t* pressedKeyCodes, int32_t* length); 1070 1071 /** 1072 * @brief Obtains the axis value of a focus axis event. 1073 * 1074 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1075 * @param axis Axis type of the focus axis event. 1076 * @return Returns the axis value of the focus axis event; returns <b>0.0</b> if any parameter error occurs. 1077 * @since 15 1078 */ 1079 double OH_ArkUI_FocusAxisEvent_GetAxisValue(const ArkUI_UIInputEvent* event, int32_t axis); 1080 1081 /** 1082 * @brief Sets whether to prevent a focus axis event from bubbling up. 1083 * 1084 * @param event Indicates the pointer to the current UI input event. 1085 * @param stopPropagation Indicates whether to stop event propagation. 1086 * @return Returns the result code. 1087 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1088 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1089 * @since 15 1090 */ 1091 int32_t OH_ArkUI_FocusAxisEvent_SetStopPropagation(const ArkUI_UIInputEvent* event, bool stopPropagation); 1092 1093 /** 1094 * @brief Obtains the width of the component hit by an event. 1095 * 1096 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1097 * @return Returns the width of the component hit by the event; returns <b>0.0f</b> if any parameter error occurs. 1098 * @since 17 1099 */ 1100 float OH_ArkUI_UIInputEvent_GetEventTargetWidth(const ArkUI_UIInputEvent* event); 1101 1102 /** 1103 * @brief Obtains the height of the component hit by an event. 1104 * 1105 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1106 * @return Returns the height of the component hit by the event; returns <b>0.0f</b> if any parameter error occurs. 1107 * @since 17 1108 */ 1109 float OH_ArkUI_UIInputEvent_GetEventTargetHeight(const ArkUI_UIInputEvent* event); 1110 1111 /** 1112 * @brief Obtains the X coordinate of the component hit by an event. 1113 * 1114 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1115 * @return Returns the X coordinate of the component hit by the event; returns <b>0.0f</b> if any parameter error occurs. 1116 * @since 17 1117 */ 1118 float OH_ArkUI_UIInputEvent_GetEventTargetPositionX(const ArkUI_UIInputEvent* event); 1119 1120 /** 1121 * @brief Obtains the Y coordinate of the component hit by an event. 1122 * 1123 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1124 * @return Returns the Y coordinate of the component hit by the event; 1125 * returns <b>0.0f</b> if any parameter error occurs. 1126 * @since 17 1127 */ 1128 float OH_ArkUI_UIInputEvent_GetEventTargetPositionY(const ArkUI_UIInputEvent* event); 1129 1130 /** 1131 * @brief Obtains the global X coordinate of the component hit by an event. 1132 * 1133 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1134 * @return Returns the global X coordinate of the component hit by the event; 1135 * returns <b>0.0f</b> if any parameter error occurs. 1136 * @since 17 1137 */ 1138 float OH_ArkUI_UIInputEvent_GetEventTargetGlobalPositionX(const ArkUI_UIInputEvent* event); 1139 1140 /** 1141 * @brief Obtains the global Y coordinate of the component hit by an event. 1142 * 1143 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1144 * @return Returns the global Y coordinate of the component hit by the event; 1145 * returns <b>0.0f</b> if any parameter error occurs. 1146 * @since 17 1147 */ 1148 float OH_ArkUI_UIInputEvent_GetEventTargetGlobalPositionY(const ArkUI_UIInputEvent* event); 1149 1150 /** 1151 * @brief Checks whether the cursor is hovering over this component. 1152 * 1153 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1154 * @return Returns <b>true</b> if the cursor is hovering over the current component. 1155 * Returns <b>false</b> if the cursor is not hovering over the current component. 1156 * @since 17 1157 */ 1158 bool OH_ArkUI_HoverEvent_IsHovered(const ArkUI_UIInputEvent* event); 1159 1160 /** 1161 * @brief Obtains the modifier key states for a UI input event. 1162 * This API outputs the state of all modifier keys at the time of the event through the <b>keys</b> parameter. 1163 * You can determine which keys are pressed by performing bitwise operations with the modifier key types defined 1164 * in {@link ArkUI_ModifierKeyName}. 1165 * 1166 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1167 * @param keys Pointer to a variable where the current combination of pressed modifier keys will be returned. 1168 * The application can use bitwise operations to determine the state of each modifier key. 1169 * @return Result code. 1170 * {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1171 * {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1172 * @since 17 1173 */ 1174 int32_t OH_ArkUI_UIInputEvent_GetModifierKeyStates(const ArkUI_UIInputEvent* event, uint64_t* keys); 1175 1176 /** 1177 * @brief Obtains the press time of a specified touch point. This API is effective only for touch events. 1178 * 1179 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1180 * @param pointerIndex Index of the target touch point in the multi-touch data list. 1181 * @return Returns the press time of the specific touch point; returns <b>0</b> if any parameter error occurs. 1182 * @since 15 1183 */ 1184 int64_t OH_ArkUI_PointerEvent_GetPressedTimeByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); 1185 1186 /** 1187 * @brief Obtains the x-axis offset of the mouse pointer position relative to the position in the previously reported 1188 * mouse event. This value may be less than the difference between the two reported X coordinates when the mouse pointer 1189 * is near the screen edge. 1190 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1191 * @return Returns the x-axis offset of the mouse pointer position relative to the position in the previously reported 1192 * mouse event; returns <b>0.0f</b> if any parameter error occurs. 1193 * @since 15 1194 */ 1195 float OH_ArkUI_MouseEvent_GetRawDeltaX(const ArkUI_UIInputEvent* event); 1196 1197 /** 1198 * @brief Obtains the y-axis offset of the mouse pointer position relative to the position in the previously reported 1199 * mouse event. This value may be less than the difference between the two reported Y coordinates when the mouse pointer 1200 * is near the screen edge. 1201 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1202 * @return Returns the y-axis offset of the mouse pointer position relative to the position in the previously reported 1203 * mouse event; returns <b>0.0f</b> if any parameter error occurs. 1204 * @since 15 1205 */ 1206 float OH_ArkUI_MouseEvent_GetRawDeltaY(const ArkUI_UIInputEvent* event); 1207 1208 /** 1209 * @brief Obtains the pressed buttons from a mouse event. 1210 * 1211 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1212 * @param pressedButtons Array of the pressed buttons. An int array must be created beforehand to store the pressed 1213 * buttons. 1214 * @param length Length of the passed pressedButtons array (when used as an input parameter); 1215 * number of the buttons pressed (when used as an output parameter). 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_BUFFER_SIZE_ERROR} if the given buffer size is insufficient. 1219 * @since 15 1220 */ 1221 int32_t OH_ArkUI_MouseEvent_GetPressedButtons( 1222 const ArkUI_UIInputEvent* event, int32_t* pressedButtons, int32_t* length); 1223 1224 /** 1225 * @brief Obtains the ID of the screen where the UI input event occurs. 1226 * 1227 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1228 * @return Returns the screen ID; returns <b>0</b> if any parameter error occurs. 1229 * @since 15 1230 */ 1231 int32_t OH_ArkUI_UIInputEvent_GetTargetDisplayId(const ArkUI_UIInputEvent* event); 1232 1233 /** 1234 * @brief Sets whether to enable axis event propagation (bubbling). By default, axis events do not bubble and are 1235 * only sent to the first component that can respond to axis events. You can enable axis event bubbling 1236 * to allow the current event to be passed to the next ancestor component in the response chain 1237 * that can handle axis events. 1238 * This API cannot be used on axis events obtained from gesture events. 1239 * 1240 * @param event Pointer to the UI input event. 1241 * @param propagation Whether to enable event propagation. 1242 * @return Result code. 1243 * {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1244 * {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1245 * @since 17 1246 */ 1247 int32_t OH_ArkUI_AxisEvent_SetPropagation(const ArkUI_UIInputEvent* event, bool propagation); 1248 1249 /** 1250 * @brief Obtains the scroll step coefficient for a wheel-based axis event. 1251 * This API returns the user-configured scroll scale factor factor. 1252 * 1253 * @param event Pointer to the UI input event. 1254 * @return Scroll step configuration of the mouse wheel axis event. 1255 * @since 17 1256 */ 1257 int32_t OH_ArkUI_AxisEvent_GetScrollStep(const ArkUI_UIInputEvent* event); 1258 1259 /** 1260 * @brief Creates a cloned event pointer based on an event pointer. This API is effective only for touch events. 1261 * 1262 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1263 * @param clonedEvent Pointer to the cloned <b>ArkUI_UIInputEvent</b> object. 1264 * @return Result code. 1265 * {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1266 * {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1267 * @since 15 1268 */ 1269 int32_t OH_ArkUI_PointerEvent_CreateClonedEvent(const ArkUI_UIInputEvent* event, ArkUI_UIInputEvent** clonedEvent); 1270 1271 /** 1272 * @brief Destroys a cloned event pointer. 1273 * 1274 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1275 * @return Returns the result code. 1276 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1277 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1278 * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the input event pointer is not a 1279 * cloned event pointer. 1280 * @since 15 1281 */ 1282 int32_t OH_ArkUI_PointerEvent_DestroyClonedEvent(const ArkUI_UIInputEvent* event); 1283 1284 /** 1285 * @brief Sets the X and Y coordinates of a cloned event relative to the upper left corner of the current component. 1286 * 1287 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1288 * @param x X coordinate of the event relative to the upper left corner of the current component. 1289 * @param y Y coordinate of the event relative to the upper left corner of the current component. 1290 * @return Returns the result code. 1291 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1292 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1293 * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the input event pointer is not a 1294 * cloned event pointer. 1295 * @since 15 1296 */ 1297 int32_t OH_ArkUI_PointerEvent_SetClonedEventLocalPosition(const ArkUI_UIInputEvent* event, float x, float y); 1298 1299 /** 1300 * @brief Sets the X and Y coordinates of a specific contact point of a cloned event relative to the upper left corner 1301 * of the current component. 1302 * 1303 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1304 * @param x X coordinate of the event relative to the upper left corner of the current component. 1305 * @param y Y coordinate of the event relative to the upper left corner of the current component. 1306 * @param pointerIndex Index of the target touch point in the multi-touch data list. 1307 * @return Returns the result code. 1308 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1309 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1310 * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the input event pointer is not a 1311 * cloned event pointer. 1312 * @since 15 1313 */ 1314 int32_t OH_ArkUI_PointerEvent_SetClonedEventLocalPositionByIndex( 1315 const ArkUI_UIInputEvent* event, float x, float y, int32_t pointerIndex); 1316 1317 /** 1318 * @brief Sets the action type of a cloned event. 1319 * 1320 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1321 * @param actionType Action type of the cloned event. 1322 * @return Returns the result code. 1323 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1324 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1325 * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the input event pointer is not a 1326 * cloned event pointer. 1327 * @since 15 1328 */ 1329 int32_t OH_ArkUI_PointerEvent_SetClonedEventActionType(const ArkUI_UIInputEvent* event, int32_t actionType); 1330 1331 /** 1332 * @brief Sets the touch point ID of a cloned pointer event. 1333 * 1334 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1335 * @param fingerId ID of the touch point that triggers the event. 1336 * @return Returns the result code. 1337 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1338 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1339 * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the input event pointer is not a 1340 * cloned event pointer. 1341 * @since 15 1342 */ 1343 int32_t OH_ArkUI_PointerEvent_SetClonedEventChangedFingerId(const ArkUI_UIInputEvent* event, int32_t fingerId); 1344 1345 /** 1346 * @brief Sets the touch point ID of a specific contact point of a cloned event. 1347 * 1348 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1349 * @param fingerId Touch point ID of the specific contact point. 1350 * @param pointerIndex Index of the target touch point in the multi-touch data list. 1351 * @return Returns the result code. 1352 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1353 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1354 * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the input event pointer is not a 1355 * cloned event pointer. 1356 * @since 15 1357 */ 1358 int32_t OH_ArkUI_PointerEvent_SetClonedEventFingerIdByIndex( 1359 const ArkUI_UIInputEvent* event, int32_t fingerId, int32_t pointerIndex); 1360 1361 /** 1362 * @brief Posts a cloned event to a specific node. 1363 * 1364 * @param node Target node. 1365 * @param event Pointer to an <b>ArkUI_UIInputEvent</b> object. 1366 * @return Returns the result code. 1367 * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. 1368 * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. 1369 * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the input event pointer is not a 1370 * cloned event pointer. 1371 * Returns {@link ARKUI_ERROR_CODE_POST_CLONED_COMPONENT_STATUS_ABNORMAL} 1372 * if the component status abnormal. 1373 * Returns {@link ARKUI_ERROR_CODE_POST_CLONED_NO_COMPONENT_HIT_TO_RESPOND_TO_THE_EVENT} 1374 * if no component hit to response to the event. 1375 * @since 15 1376 */ 1377 int32_t OH_ArkUI_PointerEvent_PostClonedEvent(ArkUI_NodeHandle node, const ArkUI_UIInputEvent* event); 1378 1379 /** 1380 * @brief Use this method to obtain the execution status of the latest UI input related method. 1381 * 1382 * In most cases, this method is unnecessary unless you need to determine if the return value indicates an error. 1383 * Here's an example of usage: For return values like float (where 0.0 doesn't indicate an error), use GetLatestStatus 1384 * to confirm if an error occurred. 1385 * float x = OH_ArkUI_PointerEvent_GetX(event); 1386 * if (ARKUI_ERROR_CODE_NO_ERROR != OH_ArkUI_UIInputEvent_GetLatestStatus()) { 1387 * // error 1388 * return; 1389 * } 1390 * Note: The system clears the status of the previous function call each time a UIInput-related function is executed, 1391 * ensuring you always get the latest status. 1392 * 1393 * @return Returns the ArkUI_ErrorCode. 1394 * @since 20 1395 */ 1396 ArkUI_ErrorCode OH_ArkUI_UIInputEvent_GetLatestStatus(); 1397 1398 #ifdef __cplusplus 1399 }; 1400 #endif 1401 1402 #endif // _ARKUI_UI_INPUT_EVENT_H_ 1403 /** @} */ 1404