From 2940ed2b97ff162f5114bae92f6e490d3cc94fa2 Mon Sep 17 00:00:00 2001 From: zhouchaobo Date: Tue, 5 Mar 2024 20:03:45 +0800 Subject: [PATCH] feature_intercept interface Signed-off-by: zhouchaobo Change-Id: Ib7a4a511e7f13cf2fe91897dbd5a981d6d063619 --- arkui/ace_engine/native/libace.ndk.json | 4 +++ arkui/ace_engine/native/native_event.h | 27 +++++++++++++++++++ .../native/native_interface_xcomponent.h | 14 ++++++++++ 3 files changed, 45 insertions(+) diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index 3ce74b73e1b..cd4e28a3b4a 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -158,5 +158,9 @@ { "first_introduced": "12", "name": "OH_NativeXComponent_SetNeedSoftKeyboard" + }, + { + "first_introduced": "12", + "name": "OH_NativeXComponent_RegisterOnTouchInterceptCallback" } ] \ No newline at end of file diff --git a/arkui/ace_engine/native/native_event.h b/arkui/ace_engine/native/native_event.h index 923e78f50d7..a40143b8670 100644 --- a/arkui/ace_engine/native/native_event.h +++ b/arkui/ace_engine/native/native_event.h @@ -225,6 +225,33 @@ typedef struct { bool preventDefault; } ArkUI_NodeTouchEvent; +/** + * @brief Enumerates the hit test modes. + * + * @since 12 + */ +typedef enum { + /** Both the node and its child node respond to the hit test of a touch event, but its sibling node is blocked from + * the hit test. + */ + HTM_DEFAULT = 0, + + /** The node responds to the hit test of a touch event, but its child node and sibling node are blocked from the hit + * test. + */ + HTM_BLOCK, + + /** Both the node and its child node respond to the hit test of a touch event, and its sibling node is also + * considered during the hit test. + */ + HTM_TRANSPARENT, + + /** The node does not respond to the hit test of a touch event, but its child node and sibling node are considered + * during the hit test. + */ + HTM_NONE, +} HitTestMode; + #ifdef __cplusplus }; #endif diff --git a/arkui/ace_engine/native/native_interface_xcomponent.h b/arkui/ace_engine/native/native_interface_xcomponent.h index cf971dc0432..2e622d8f0f8 100644 --- a/arkui/ace_engine/native/native_interface_xcomponent.h +++ b/arkui/ace_engine/native/native_interface_xcomponent.h @@ -42,6 +42,7 @@ #include #endif +#include "arkui/native_event.h" #include "arkui/native_type.h" #include "arkui/ui_input_event.h" @@ -679,6 +680,19 @@ int32_t OH_NativeXComponent_RegisterUIInputEventCallback( */ int32_t OH_NativeXComponent_SetNeedSoftKeyboard(OH_NativeXComponent* component, bool needSoftKeyboard); +/** + * @brief Registers a custom event intercept callback for this OH_NativeXComponent and enables the callback + * during the hit test. + * + * @param component Indicates the pointer to the OH_NativeXComponent instance. + * @param callback Indicates the pointer to the custom event intercept callback. + * @return Returns 0 if success. + * Returns 401 if a parameter exception occurs. + * @since 12 + */ +int32_t OH_NativeXComponent_RegisterOnTouchInterceptCallback( + OH_NativeXComponent* component, HitTestMode (*callback)(OH_NativeXComponent* component, ArkUI_UIInputEvent* event)); + #ifdef __cplusplus }; #endif -- Gitee