diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index dc3d30be4c1491c195b569a958e86367b7945d40..a4fbe4ee24b2e89a9fa695e70ef799346a505b0a 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -4138,5 +4138,53 @@ { "first_introduced": "21", "name": "OH_ArkUI_ContentTransitionEffect_Create" + }, + { + "first_introduced": "22", + "name": "OH_ArkUI_NodeEvent_GetTouchTestInfo" + }, + { + "first_introduced": "22", + "name": "OH_ArkUI_TouchTestInfo_GetTouchTestInfoList" + }, + { + "first_introduced": "22", + "name": "OH_ArkUI_TouchTestInfoItem_GetX" + }, + { + "first_introduced": "22", + "name": "OH_ArkUI_TouchTestInfoItem_GetY" + }, + { + "first_introduced": "22", + "name": "OH_ArkUI_TouchTestInfoItem_GetWindowX" + }, + { + "first_introduced": "22", + "name": "OH_ArkUI_TouchTestInfoItem_GetWindowY" + }, + { + "first_introduced": "22", + "name": "OH_ArkUI_TouchTestInfoItem_GetXRelativeToParent" + }, + { + "first_introduced": "22", + "name": "OH_ArkUI_TouchTestInfoItem_GetYRelativeToParent" + }, + { + "first_introduced": "22", + "name": "OH_ArkUI_TouchTestInfoItem_GetChildRect" + }, + { + "first_introduced": "22", + "name": "OH_ArkUI_TouchTestInfoItem_GetChildId" + }, + { + "first_introduced": "22", + "name": "OH_ArkUI_TouchTestInfo_SetTouchResultStrategy" + }, + { + "first_introduced": "22", + "name": "OH_ArkUI_TouchTestInfo_SetTouchResultId" } ] \ No newline at end of file diff --git a/arkui/ace_engine/native/native_node.h b/arkui/ace_engine/native/native_node.h index 5cbcdce4fe3a2dc29ba2d8d8b50f0cefecea390e..213fd2232bc65d7048f91b50d2c0891e052ded1f 100644 --- a/arkui/ace_engine/native/native_node.h +++ b/arkui/ace_engine/native/native_node.h @@ -7546,6 +7546,16 @@ typedef enum { */ NODE_ON_SIZE_CHANGE = 30, + /** + * @brief Defines the pre-touch test of sub component in touch events. Called to specify how to perform the touch test on the children of this component. + * + * The event is triggered when the component is touched. \n + * When the event callback occurs, the {@link ArkUI_NodeEvent} object can be obtained from the + * {@link ArkUI_TouchTestInfo} object. \n + * @since 22 + */ + NODE_ON_CHILD_TOUCH_TEST = 31, + /** * @brief Triggers onDetectResultUpdate callback * when the text is set to TextDataDetectorConfig and recognized successfully. diff --git a/arkui/ace_engine/native/ui_input_event.h b/arkui/ace_engine/native/ui_input_event.h index 1e74a9ff75b05a103684fc1f90528b8fa5b5a80c..fbc9a7bb8c8ee897863d287d78bfdddd9d4d2cfc 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_node.h" #include "native_type.h" #include @@ -50,6 +51,34 @@ extern "C" { */ typedef struct ArkUI_UIInputEvent ArkUI_UIInputEvent; +/** + * @brief Defines the touch test info. + * + * @since 22 + */ +typedef struct ArkUI_TouchTestInfo ArkUI_TouchTestInfo; + +/** + * @brief Defines the touch test info item. + * + * @since 22 + */ +typedef struct ArkUI_TouchTestInfoItem ArkUI_TouchTestInfoItem; + +/** + * @brief Defines the touch test info item handle. + * + * @since 22 + */ +typedef ArkUI_TouchTestInfoItem* ArkUI_TouchTestInfoItemHandle; + +/** + * @brief Defines the gesture recognizer handle array. + * + * @since 22 + */ +typedef ArkUI_TouchTestInfoItemHandle* ArkUI_TouchTestInfoItemArray; + /** * @brief Enumerates the UI input event types. * @@ -279,6 +308,24 @@ enum { UI_AXIS_EVENT_ACTION_CANCEL = 4, }; +/** + * @brief Defines whether the touch event is from the left or right hand. + * + * @since 22 + */ +typedef enum { + /** Custom dispatch has no effect; the system distributes events based on the hit status of the current node. */ + ARKUI_TOUCH_TEST_STRATEGY_DEAULT = 0, + /** The specified event is forwarded to a particular child node, and the system determines whether to + * distribute the event to other sibling nodes. + */ + ARKUI_TOUCH_TEST_STRATEGY_FORWARD_COMPETITION = 1, + /** The specified event is forwarded to a particular child node, and the system no longer distributes + * the event to other sibling nodes. + */ + ARKUI_TOUCH_TEST_STRATEGY_FORWARD = 2, +} ArkUI_TouchTestStrategy; + /** * @brief Obtains the type of a UI input event. * @@ -1395,6 +1442,140 @@ int32_t OH_ArkUI_PointerEvent_PostClonedEvent(ArkUI_NodeHandle node, const ArkUI */ ArkUI_ErrorCode OH_ArkUI_UIInputEvent_GetLatestStatus(); +/** + * @brief Obtains a ArkUI_TouchTestInfo object from the specified ArkUI_NodeEvent object. + * + * @param nodeEvent Indicates the pointer to an ArkUI_NodeEvent object. + * @return Returns the pointer to an ArkUI_TouchTestInfo object. + * Returns null if the parameter passed in is invalid or is not a touch test info. + * @since 22 + */ +ArkUI_TouchTestInfo* OH_ArkUI_NodeEvent_GetTouchTestInfo(ArkUI_NodeEvent* nodeEvent); + +/** + * @brief Obtains touch test info item list in the touch test info. + * + * @param info Indicates the pointer to a touch test info. + * @param array Indicates the pointer to the array of touch test info list. + * @param size Indicates the size of the array of touch test info list. + * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. + * @since 22 + */ +ArkUI_ErrorCode OH_ArkUI_TouchTestInfo_GetTouchTestInfoList(ArkUI_TouchTestInfo* info, + ArkUI_TouchTestInfoItemArray* array, int32_t* size); + +/** + * @brief Obtains the X coordinate relative to the upper left corner of the child component from the touch test + * info item. + * + * @param info Indicates the pointer to the touch test info item. + * @return Returns the X coordinate relative to the upper left corner of the parent component. + * returns 0 if any parameter error occurs. + * @since 22 + */ +float OH_ArkUI_TouchTestInfoItem_GetX(const ArkUI_TouchTestInfoItem* info); + +/** + * @brief Obtains the Y coordinate relative to the upper left corner of the child component from the touch test + * info item. + * + * @param info Indicates the pointer to the touch test info item. + * @return Returns the Y coordinate relative to the upper left corner of the parent component. + * returns 0 if any parameter error occurs. + * @since 22 + */ +float OH_ArkUI_TouchTestInfoItem_GetY(const ArkUI_TouchTestInfoItem* info); + +/** + * @brief Obtains the X coordinate relative to the upper left corner of the current application window from the touch + * test info item. + * + * @param info Indicates the pointer to the touch test info item. + * @return Returns the X coordinate relative to the upper left corner of the current application window. + * returns 0.0f if any parameter error occurs. + * @since 22 + */ +float OH_ArkUI_TouchTestInfoItem_GetWindowX(const ArkUI_TouchTestInfoItem* info); + +/** + * @brief Obtains the Y coordinate relative to the upper left corner of the current application window from the touch + * test info item. + * + * @param info Indicates the pointer to the touch test info item. + * @return Returns the Y coordinate relative to the upper left corner of the current application window. + * returns 0.0f if any parameter error occurs. + * @since 22 + */ +float OH_ArkUI_TouchTestInfoItem_GetWindowY(const ArkUI_TouchTestInfoItem* info); + +/** + * @brief Obtains the X coordinate relative to the upper left corner of the parent component from the touch test + * info item. + * + * @param info Indicates the pointer to the touch test info item. + * @return Returns the X coordinate relative to the upper left corner of the parent component. + * returns 0 if any parameter error occurs. + * @since 22 + */ +float OH_ArkUI_TouchTestInfoItem_GetXRelativeToParent(const ArkUI_TouchTestInfoItem* info); + +/** + * @brief Obtains the Y coordinate relative to the upper left corner of the parent component from the touch test + * info item. + * + * @param info Indicates the pointer to the touch test info item. + * @return Returns the Y coordinate relative to the upper left corner of the parent component. + * returns 0 if any parameter error occurs. + * @since 22 + */ +float OH_ArkUI_TouchTestInfoItem_GetYRelativeToParent(const ArkUI_TouchTestInfoItem* info); + +/** + * @brief Obtains the sub component's frame rect info from the touch test info item. + * + * @param info Indicates the pointer to the touch test info item. + * @param childRect Indicates the pointer to the child frame rect. + * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. + * @since 22 + */ +ArkUI_ErrorCode OH_ArkUI_TouchTestInfoItem_GetChildRect(const ArkUI_TouchTestInfoItem* info, ArkUI_Rect* childRect); + +/** + * @brief Obtains the sub component's name from the touch test info item. + * + * @param info Indicates the pointer to the touch test info item. + * @param buffer Indicates the buffer. + * @param bufferSize Indicates the buffer size. + * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. + * Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH} if the buffer is not large enough. + * @since 22 + */ +ArkUI_ErrorCode OH_ArkUI_TouchTestInfoItem_GetChildId(const ArkUI_TouchTestInfoItem* info, char* buffer, + int32_t bufferSize); + +/** + * @brief Sets the touch test strategy, that is, how the component and the sub components behave during hit testing. + * + * @param info Indicates the pointer to a touch test info. + * @param strategy The touch test strategy. + * @return Result code. + * @since 22 + */ +ArkUI_ErrorCode OH_ArkUI_TouchTestInfo_SetTouchResultStrategy(const ArkUI_TouchTestInfo* info, ArkUI_TouchTestStrategy strategy); + +/** + * @brief Sets the sub component's name, that is, which sub components need to be effected during hit testing. + * + * @param info Indicates the pointer to a touch test info. + * @param id The sub component's name. + * @return Result code. + * @since 22 + */ +ArkUI_ErrorCode OH_ArkUI_TouchTestInfo_SetTouchResultId(const ArkUI_TouchTestInfo* info, const char* id); + #ifdef __cplusplus }; #endif