From 9b6f66c8fc3929f534e7ef7d1a8718350ef0cccf Mon Sep 17 00:00:00 2001 From: zhouchaobo Date: Sat, 25 Jan 2025 11:26:23 +0800 Subject: [PATCH] add post event ability to cNode Signed-off-by: zhouchaobo Change-Id: I85405d511a672f8d9d8dfbb6b18af4709e91011f --- arkui/ace_engine/native/native_type.h | 10 +++ arkui/ace_engine/native/ui_input_event.h | 109 +++++++++++++++++++++++ 2 files changed, 119 insertions(+) diff --git a/arkui/ace_engine/native/native_type.h b/arkui/ace_engine/native/native_type.h index b95363f87..760afa45f 100644 --- a/arkui/ace_engine/native/native_type.h +++ b/arkui/ace_engine/native/native_type.h @@ -2172,6 +2172,16 @@ typedef enum { ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER = 180001, /** The buffer is not large enough. */ ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH = 180002, + /** + * @error The event is not cloned pointer event. + * @since 16 + */ + ARKUI_ERROR_CODE_NOT_CLONED_POINTER_EVENT = 180003, + /** + * @error Post cloned pointer event failed. + * @since 16 + */ + ARKUI_ERROR_CODE_POST_CLONED_POINTER_EVENT_FAILED = 180004, /** * @error invalid styled string. * @since 14 diff --git a/arkui/ace_engine/native/ui_input_event.h b/arkui/ace_engine/native/ui_input_event.h index 337e4991f..0b54cc680 100644 --- a/arkui/ace_engine/native/ui_input_event.h +++ b/arkui/ace_engine/native/ui_input_event.h @@ -36,6 +36,7 @@ #ifndef _ARKUI_UI_INPUT_EVENT_H_ #define _ARKUI_UI_INPUT_EVENT_H_ +#include "native_type.h" #include #ifdef __cplusplus @@ -927,6 +928,114 @@ int32_t OH_ArkUI_MouseEvent_GetPressedButtons( */ int32_t OH_ArkUI_UIInputEvent_GetTargetDisplayId(const ArkUI_UIInputEvent* event); +/** + * @brief Create cloned pointer event from the original pointer event. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @param clonedEvent Pointer to an ArkUI_UIInputEvent pointer. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + * @since 16 + */ +int32_t OH_ArkUI_PointerEvent_CreateClonedEvent(const ArkUI_UIInputEvent* event, ArkUI_UIInputEvent** clonedEvent); + +/** + * @brief Destroy the cloned pointer event. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the event is not the cloned pointer event. + * @since 16 + */ +int32_t OH_ArkUI_PointerEvent_DestroyClonedEvent(const ArkUI_UIInputEvent* event); + +/** + * @brief Set the position relative to the upper left corner of the current component from a cloned directional + * input event. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @param x The X coordinate relative to the upper left corner of the current component, in px. + * @param y The Y coordinate relative to the upper left corner of the current component, in px. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the event is not the cloned pointer event. + * @since 16 + */ +int32_t OH_ArkUI_PointerEvent_SetClonedEventLocalPosition(const ArkUI_UIInputEvent* event, float x, float y); + +/** + * @brief Set the position of a specific touch point relative to the upper left corner of the current component + * from a cloned directional input event. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @param x The X coordinate relative to the upper left corner of the current component, in px. + * @param y The Y coordinate relative to the upper left corner of the current component, in px. + * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the event is not the cloned pointer event. + * @since 16 + */ +int32_t OH_ArkUI_PointerEvent_SetClonedEventLocalPositionByIndex(const ArkUI_UIInputEvent* event, float x, float y, int32_t pointerIndex); + +/** + * @brief Set the action type of the cloned pointer event. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @param actionType The action type of pointer event. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the event is not the cloned pointer event. + * @since 16 + */ +int32_t OH_ArkUI_PointerEvent_SetClonedEventActionType(const ArkUI_UIInputEvent* event, int32_t actionType); + +/** + * @brief Set the ID of the touch point that triggers the current cloned pointer event. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @param fingerId The ID of the touch point that triggers the current pointer event. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the event is not the cloned pointer event. + * @since 16 + */ +int32_t OH_ArkUI_PointerEvent_SetClonedEventChangedFingerId(const ArkUI_UIInputEvent* event, int32_t fingerId); + +/** + * @brief Set the ID of a touch point from a cloned directional input event. + * + * @param event Pointer to an ArkUI_UIInputEvent object. + * @param fingerId The ID of the touch point. + * @param pointerIndex Indicates the index of the target touch point in the multi-touch data list. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + * Returns {@link ARKUI_ERROR_CODE_NON_CLONED_POINTER_EVENT} if the event is not the cloned pointer event. + * @since 16 + */ +int32_t OH_ArkUI_PointerEvent_SetClonedEventFingerIdByIndex(const ArkUI_UIInputEvent* event, int32_t fingerId, int32_t pointerIndex); + +/** + * @brief Post pointer event to a specific node. + * + * @param node Indicates the target node. + * @param event Pointer to an ArkUI_UIInputEvent object. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + * Returns {@link ARKUI_ERROR_CODE_POST_CLONED_POINTER_EVENT_FAILED} if post the cloned pointer event failed. + * @since 16 + */ +int32_t OH_ArkUI_PointerEvent_PostClonedEvent(ArkUI_NodeHandle node, const ArkUI_UIInputEvent* event); + #ifdef __cplusplus }; #endif -- Gitee