native_node_napi.h
Overview
Provides the APIs used to convert FrameNode on the ArkTS side to NodeHandle.
File to include: <arkui/native_node_napi.h>
Library: libace_ndk.z.so
System capability: SystemCapability.ArkUI.ArkUI.Full
Since: 12
Related module: ArkUI_NativeModule
Sample: native_node_napi
Summary
Functions
| Name | Description |
|---|---|
| int32_t OH_ArkUI_GetNodeHandleFromNapiValue(napi_env env, napi_value frameNode, ArkUI_NodeHandle* handle) | Obtains an ArkUI_NodeHandle object on the native side mapped from the FrameNode object created on the ArkTS side. |
| int32_t OH_ArkUI_GetContextFromNapiValue(napi_env env, napi_value value, ArkUI_ContextHandle* context) | Obtains an ArkUI_ContextHandle object on the native side mapped from the UIContext object created on the ArkTS side. |
| int32_t OH_ArkUI_GetNodeContentFromNapiValue(napi_env env, napi_value value, ArkUI_NodeContentHandle* content) | Obtains an ArkUI_NodeContentHandle object on the native side mapped from the NodeContent object created on the ArkTS side. |
| int32_t OH_ArkUI_GetDrawableDescriptorFromNapiValue(napi_env env, napi_value value, ArkUI_DrawableDescriptor** drawableDescriptor) | Maps a DrawableDescriptor object on the ArkTS side to an ArkUI_DrawableDescriptor object on the native side. |
| int32_t OH_ArkUI_GetDrawableDescriptorFromResourceNapiValue(napi_env env, napi_value value, ArkUI_DrawableDescriptor** drawableDescriptor) | Converts the resource object obtained through $r() on the ArkTS side into an ArkUI_DrawableDescriptor object that can be used on the native side. |
| ArkUI_ErrorCode OH_ArkUI_GetNavigationId(ArkUI_NodeHandle node, char* buffer, int32_t bufferSize, int32_t* writeLength) | Obtains the ID of the Navigation component where the specified node is located. |
| ArkUI_ErrorCode OH_ArkUI_GetNavDestinationName(ArkUI_NodeHandle node, char* buffer, int32_t bufferSize, int32_t* writeLength) | Obtains the name of the NavDestination component where the specified node is located. |
| ArkUI_ErrorCode OH_ArkUI_GetNavStackLength(ArkUI_NodeHandle node, int32_t* length) | Obtains the length of the Navigation stack where the specified node is located. |
| ArkUI_ErrorCode OH_ArkUI_GetNavDestinationNameByIndex(ArkUI_NodeHandle node, int32_t index, char* buffer, int32_t bufferSize, int32_t* writeLength) | Obtains the page name that matches the specified index in the navigation stack where the specified node is located. The index starts from 0, which indicates the bottom of the stack. |
| ArkUI_ErrorCode OH_ArkUI_GetNavDestinationId(ArkUI_NodeHandle node, char* buffer, int32_t bufferSize, int32_t* writeLength) | Obtains the ID of the NavDestination component where the specified node is located. |
| ArkUI_ErrorCode OH_ArkUI_GetNavDestinationState(ArkUI_NodeHandle node, ArkUI_NavDestinationState* state) | Obtains the state of the NavDestination component where the specified node is located. |
| ArkUI_ErrorCode OH_ArkUI_GetNavDestinationIndex(ArkUI_NodeHandle node, int32_t* index) | Obtains the index of the NavDestination component where the specified node is located in the navigation stack. |
| napi_value OH_ArkUI_GetNavDestinationParam(ArkUI_NodeHandle node) | Obtains the parameter of the NavDestination component where the specified node is located. |
| ArkUI_ErrorCode OH_ArkUI_GetRouterPageIndex(ArkUI_NodeHandle node, int32_t* index) | Obtains the index of the page where the specified node is located in the page stack for routing. |
| ArkUI_ErrorCode OH_ArkUI_GetRouterPageName(ArkUI_NodeHandle node, char* buffer, int32_t bufferSize, int32_t* writeLength) | Obtains the name of the page where the specified node is located. |
| ArkUI_ErrorCode OH_ArkUI_GetRouterPagePath(ArkUI_NodeHandle node, char* buffer, int32_t bufferSize, int32_t* writeLength) | Obtains the path to the page where the specified node is located. |
| ArkUI_ErrorCode OH_ArkUI_GetRouterPageState(ArkUI_NodeHandle node, ArkUI_RouterPageState* state) | Obtains the state of the page where the specified node is located. |
| ArkUI_ErrorCode OH_ArkUI_GetRouterPageId(ArkUI_NodeHandle node, char* buffer, int32_t bufferSize, int32_t* writeLength) | Obtains the ID of the page where the specified node is located. |
| ArkUI_ErrorCode OH_ArkUI_InitModuleForArkTSEnv(napi_env env) | Initializes ArkUI-related APIs for the specified context environment. This function must not be called from a non-UI thread; otherwise, the program will actively abort. |
| void OH_ArkUI_NotifyArkTSEnvDestroy(napi_env env) | Notifies that the specified context environment has been destroyed. This function must not be called from a non-UI thread; otherwise, the program will actively abort. |
| int32_t OH_ArkUI_PostFrameCallback(ArkUI_ContextHandle uiContext, void* userData,void (*callback)(uint64_t nanoTimestamp, uint32_t frameCount, void* userData)) | Registers a callback function to be executed during the next frame rendering. This function must not be called from a non-UI thread; otherwise, the program will actively abort. |
| int32_t OH_ArkUI_PostIdleCallback(ArkUI_ContextHandle uiContext, void* userData,void (*callback)(uint64_t nanoTimeLeft, uint32_t frameCount, void* userData)) | Registers a callback function that will be executed after the rendering of the next frame is completed if there is more than 1 ms of idle time remaining before the next VSync signal arrives. If the remaining time is less than 1 ms, the callback will be deferred until a subsequent frame where more than 1 ms of idle time is available. If there is no next frame scheduled, one will be automatically requested. |
| ArkUI_ErrorCode OH_ArkUI_EnableEventPassthrough(ArkUI_ContextHandle uiContext, bool enabled, ArkUI_RawInputEventType type) | Enables or disables event passthrough. Event passthrough indicates that an event is directly delivered to a component without resampling during event distribution. |
Function Description
OH_ArkUI_GetNodeHandleFromNapiValue()
int32_t OH_ArkUI_GetNodeHandleFromNapiValue(napi_env env, napi_value frameNode, ArkUI_NodeHandle* handle)
Description
Obtains an ArkUI_NodeHandle object on the native side mapped from the FrameNode object created on the ArkTS side.
Since: 12
Parameters
| Name | Description |
|---|---|
| napi_env env | Pointer to the Node-API environment. |
| napi_value frameNode | FrameNode object created on the ArkTS side. |
| ArkUI_NodeHandle* handle | Pointer to the ArkUI_NodeHandle. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_GetContextFromNapiValue()
int32_t OH_ArkUI_GetContextFromNapiValue(napi_env env, napi_value value, ArkUI_ContextHandle* context)
Description
Obtains an ArkUI_ContextHandle object on the native side mapped from a UIContext object created on the ArkTS side.
Since: 12
Parameters
| Name | Description |
|---|---|
| napi_env env | Pointer to the Node-API environment. |
| napi_value value | UIContext object created on the ArkTS side. |
| ArkUI_ContextHandle* context | Pointer to the ArkUI_ContextHandle. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_GetNodeContentFromNapiValue()
int32_t OH_ArkUI_GetNodeContentFromNapiValue(napi_env env, napi_value value, ArkUI_NodeContentHandle* content)
Description
Obtains an ArkUI_NodeContentHandle object on the native side mapped from the NodeContent object created on the ArkTS side.
Since: 12
Parameters
| Name | Description |
|---|---|
| napi_env env | Pointer to the Node-API environment. |
| napi_value value | NodeContent object created on the ArkTS side. |
| ArkUI_NodeContentHandle* content | Pointer to the ArkUI_NodeContentHandle. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_GetDrawableDescriptorFromNapiValue()
int32_t OH_ArkUI_GetDrawableDescriptorFromNapiValue(napi_env env, napi_value value, ArkUI_DrawableDescriptor** drawableDescriptor)
Description
Maps the DrawableDescriptor object created on the ArkTS side to the ArkUI_DrawableDescriptor object on the native side.
Since: 12
Parameters
| Name | Description |
|---|---|
| napi_env env | Pointer to the Node-API environment. |
| napi_value value | DrawableDescriptor object created on the ArkTS side. |
| ArkUI_DrawableDescriptor** drawableDescriptor | Double pointer used to receive the ArkUI_DrawableDescriptor object. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_GetDrawableDescriptorFromResourceNapiValue()
int32_t OH_ArkUI_GetDrawableDescriptorFromResourceNapiValue(napi_env env, napi_value value, ArkUI_DrawableDescriptor** drawableDescriptor)
Description
Converts the resource object obtained by $r() on the ArkTS side to the ArkUI_DrawableDescriptor object that can be used on the native side.
Since: 12
Parameters
| Name | Description |
|---|---|
| napi_env env | Pointer to the Node-API environment. |
| napi_value value | $r resource object created on the ArkTS side. |
| ArkUI_DrawableDescriptor** drawableDescriptor | Double pointer used to receive the ArkUI_DrawableDescriptor object. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_GetNavigationId()
ArkUI_ErrorCode OH_ArkUI_GetNavigationId(ArkUI_NodeHandle node, char* buffer, int32_t bufferSize, int32_t* writeLength)
Description
Obtains the ID of the Navigation component where the specified node is located.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Target node. |
| char* buffer | Pointer to the buffer to which the obtained ID is written. |
| int32_t bufferSize | Buffer size. |
| int32_t* writeLength | Pointer to the length of the string written to the buffer when ARKUI_ERROR_CODE_NO_ERROR is returned; pointer to the minimum size of the buffer required to hold the target when ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR is returned. |
Return value
| Type | Description |
|---|---|
| ArkUI_ErrorCode | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. Returns ARKUI_ERROR_CODE_GET_INFO_FAILED if information fails to be obtained, possibly because the specified node is not in the navigation stack. Returns ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR if the data size exceeds the specified buffer size. |
OH_ArkUI_GetNavDestinationName()
ArkUI_ErrorCode OH_ArkUI_GetNavDestinationName(ArkUI_NodeHandle node, char* buffer, int32_t bufferSize, int32_t* writeLength)
Description
Obtains the name of the NavDestination component where the specified node is located.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Target node. |
| char* buffer | Pointer to the buffer to which the obtained name is written. |
| int32_t bufferSize | Buffer size. |
| int32_t* writeLength | Pointer to the length of the string written to the buffer when ARKUI_ERROR_CODE_NO_ERROR is returned; pointer to the minimum size of the buffer required to hold the target when ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR is returned. |
Return value
| Type | Description |
|---|---|
| ArkUI_ErrorCode | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. Returns ARKUI_ERROR_CODE_GET_INFO_FAILED if information fails to be obtained, possibly because the specified node is not in the navigation stack. Returns ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR if the specified buffer size is smaller than the minimum buffer size required to hold the target. |
OH_ArkUI_GetNavStackLength()
ArkUI_ErrorCode OH_ArkUI_GetNavStackLength(ArkUI_NodeHandle node, int32_t* length)
Description
Obtains the length of the Navigation stack where the specified node is located.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Target node. |
| int32_t* length | Pointer to the length of the navigation stack. The result, if obtained successfully, is written back to this parameter. |
Return value
| Type | Description |
|---|---|
| ArkUI_ErrorCode | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. Returns ARKUI_ERROR_CODE_GET_INFO_FAILED if information fails to be obtained, possibly because the specified node is not in the navigation stack. |
OH_ArkUI_GetNavDestinationNameByIndex()
ArkUI_ErrorCode OH_ArkUI_GetNavDestinationNameByIndex(ArkUI_NodeHandle node, int32_t index, char* buffer, int32_t bufferSize, int32_t* writeLength)
Description
Obtains the name of the page in the navigation stack where the specified node is located based on the given index. The index starts from 0, which indicates the bottom of the stack.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Target node. |
| int32_t index | Index of the target page in the navigation stack. |
| char* buffer | Pointer to the buffer to which the obtained name is written. |
| int32_t bufferSize | Buffer size. |
| int32_t* writeLength | Pointer to the length of the string written to the buffer when ARKUI_ERROR_CODE_NO_ERROR is returned; pointer to the minimum size of the buffer required to hold the target when ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR is returned. |
Return value
| Type | Description |
|---|---|
| ArkUI_ErrorCode | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_NODE_INDEX_INVALID if the index is invalid. Returns ARKUI_ERROR_CODE_GET_INFO_FAILED if information fails to be obtained, possibly because the specified node is not in the navigation stack. Returns ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR if the specified buffer size is smaller than the minimum buffer size required to hold the target. |
OH_ArkUI_GetNavDestinationId()
ArkUI_ErrorCode OH_ArkUI_GetNavDestinationId(ArkUI_NodeHandle node, char* buffer, int32_t bufferSize, int32_t* writeLength)
Description
Obtains the ID of the NavDestination component where the specified node is located.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Target node. |
| char* buffer | Pointer to the buffer to which the obtained ID is written. |
| int32_t bufferSize | Buffer size. |
| int32_t* writeLength | Pointer to the length of the string written to the buffer when ARKUI_ERROR_CODE_NO_ERROR is returned; pointer to the minimum size of the buffer required to hold the target when ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR is returned. |
Return value
| Type | Description |
|---|---|
| ArkUI_ErrorCode | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. Returns ARKUI_ERROR_CODE_GET_INFO_FAILED if information fails to be obtained, possibly because the specified node is not in the navigation stack. Returns ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR if the data size exceeds the specified buffer size. |
OH_ArkUI_GetNavDestinationState()
ArkUI_ErrorCode OH_ArkUI_GetNavDestinationState(ArkUI_NodeHandle node, ArkUI_NavDestinationState* state)
Description
Obtains the state of the NavDestination component where the specified node is located.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Target node. |
| ArkUI_NavDestinationState* state | Pointer to the state of the NavDestination component. The result, if obtained successfully, is written back to this parameter. |
Return value
| Type | Description |
|---|---|
| ArkUI_ErrorCode | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. Returns ARKUI_ERROR_CODE_GET_INFO_FAILED if information fails to be obtained, possibly because the specified node is not in the navigation stack. |
OH_ArkUI_GetNavDestinationIndex()
ArkUI_ErrorCode OH_ArkUI_GetNavDestinationIndex(ArkUI_NodeHandle node, int32_t* index)
Description
Obtains the index of the NavDestination component where the specified node is located in the navigation stack.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Target node. |
| int32_t* index | Pointer to the zero-based index. |
Return value
| Type | Description |
|---|---|
| ArkUI_ErrorCode | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. Returns ARKUI_ERROR_CODE_GET_INFO_FAILED if information fails to be obtained, possibly because the specified node is not in the navigation stack. |
OH_ArkUI_GetNavDestinationParam()
napi_value OH_ArkUI_GetNavDestinationParam(ArkUI_NodeHandle node)
Description
Obtains the parameter of the NavDestination component where the specified node is located.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Target node. |
Return value
| Type | Description |
|---|---|
| napi_value | Parameter object. Returns an empty value if the parameters do not exist or the specified node is null. |
OH_ArkUI_GetRouterPageIndex()
ArkUI_ErrorCode OH_ArkUI_GetRouterPageIndex(ArkUI_NodeHandle node, int32_t* index)
Description
Obtains the index of the Router page stack where the specified node is located.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Target node. |
| int32_t* index | Pointer to the one-based index. |
Return value
| Type | Description |
|---|---|
| ArkUI_ErrorCode | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if the node or index specified is invalid. Returns ARKUI_ERROR_CODE_GET_INFO_FAILED if information fails to be obtained, possibly because the specified node is not in the navigation stack. |
OH_ArkUI_GetRouterPageName()
ArkUI_ErrorCode OH_ArkUI_GetRouterPageName(ArkUI_NodeHandle node, char* buffer, int32_t bufferSize, int32_t* writeLength)
Description
Obtains the name of the Router page where the specified node is located.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Target node. |
| char* buffer | Pointer to the buffer to which the obtained name is written. |
| int32_t bufferSize | Buffer size. |
| int32_t* writeLength | Pointer to the length of the string written to the buffer when ARKUI_ERROR_CODE_NO_ERROR is returned; pointer to the minimum size of the buffer required to hold the target when ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR is returned. |
Return value
| Type | Description |
|---|---|
| ArkUI_ErrorCode | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. Returns ARKUI_ERROR_CODE_GET_INFO_FAILED if information fails to be obtained. Returns ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR if the specified buffer size is smaller than the minimum buffer size required to hold the target. |
OH_ArkUI_GetRouterPagePath()
ArkUI_ErrorCode OH_ArkUI_GetRouterPagePath(ArkUI_NodeHandle node, char* buffer, int32_t bufferSize, int32_t* writeLength)
Description
Obtains the path of the Router page where the specified node is located.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Target node. |
| char* buffer | Pointer to the buffer to which the page path is written. |
| int32_t bufferSize | Buffer size. |
| int32_t* writeLength | Pointer to the length of the string written to the buffer when ARKUI_ERROR_CODE_NO_ERROR is returned; pointer to the minimum size of the buffer required to hold the target when ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR is returned. |
Return value
| Type | Description |
|---|---|
| ArkUI_ErrorCode | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. Returns ARKUI_ERROR_CODE_GET_INFO_FAILED if information fails to be obtained. Returns ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR if the specified buffer size is smaller than the minimum buffer size required to hold the target. |
OH_ArkUI_GetRouterPageState()
ArkUI_ErrorCode OH_ArkUI_GetRouterPageState(ArkUI_NodeHandle node, ArkUI_RouterPageState* state)
Description
Obtains the status of the Router page where the specified node is located.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Target node. |
| ArkUI_RouterPageState* state | Pointer to the status of the Router page. The result, if obtained successfully, is written back to this parameter. |
Return value
| Type | Description |
|---|---|
| ArkUI_ErrorCode | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. Returns ARKUI_ERROR_CODE_GET_INFO_FAILED if information fails to be obtained. |
OH_ArkUI_GetRouterPageId()
ArkUI_ErrorCode OH_ArkUI_GetRouterPageId(ArkUI_NodeHandle node, char* buffer, int32_t bufferSize, int32_t* writeLength)
Description
Obtains the ID of the Router page where the specified node is located.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Target node. |
| char* buffer | Pointer to the buffer to which the page ID is written. |
| int32_t bufferSize | Buffer size. |
| int32_t* writeLength | Pointer to the length of the string written to the buffer when ARKUI_ERROR_CODE_NO_ERROR is returned; pointer to the minimum size of the buffer required to hold the target when ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR is returned. |
Return value
| Type | Description |
|---|---|
| ArkUI_ErrorCode | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. Returns ARKUI_ERROR_CODE_GET_INFO_FAILED if information fails to be obtained. Returns ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR if the data size exceeds the specified buffer size. |
OH_ArkUI_InitModuleForArkTSEnv()
ArkUI_ErrorCode OH_ArkUI_InitModuleForArkTSEnv(napi_env env)
Description
Initializes ArkUI-related APIs for the specified context environment. This function must not be called from a non-UI thread; otherwise, the program will actively abort.
Since: 20
Parameters
| Name | Description |
|---|---|
| napi_env env | Pointer to the Node-API environment. |
Return value
| Type | Description |
|---|---|
| ArkUI_ErrorCode | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if the parameter is invalid. Examples of invalid parameters include a null env pointer or failure to configure the trustlist. Returns ARKUI_ERROR_CODE_CAPI_INIT_ERROR if C API initialization failed. |
OH_ArkUI_NotifyArkTSEnvDestroy()
void OH_ArkUI_NotifyArkTSEnvDestroy(napi_env env)
Description
Notifies that the specified context environment has been destroyed. This function must not be called from a non-UI thread; otherwise, the program will actively abort.
Since: 20
Parameters
| Name | Description |
|---|---|
| napi_env env | Pointer to the Node-API environment. |
OH_ArkUI_PostFrameCallback()
int32_t OH_ArkUI_PostFrameCallback(ArkUI_ContextHandle uiContext, void* userData,void (*callback)(uint64_t nanoTimestamp, uint32_t frameCount, void* userData))
Description
Registers a callback function to be executed during the next frame rendering. This function must not be called from a non-UI thread; otherwise, the program will actively abort.
Since: 18
Parameters
| Name | Description |
|---|---|
| ArkUI_ContextHandle uiContext | Pointer to the UIContext object, which is used to bind an instance. |
| void* userData | Pointer to the custom event parameter, which is passed in the callback when the event is triggered. |
| callback | Custom callback function. |
| uint64_t nanoTimestamp | Timestamp of the frame signal. |
| uint32_t frameCount | Frame number. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_CAPI_INIT_ERROR if C API initialization failed. Returns ARKUI_ERROR_CODE_UI_CONTEXT_INVALID if the uiContext object is invalid. Returns ARKUI_ERROR_CODE_CALLBACK_INVALID if the callback function is invalid. |
OH_ArkUI_PostIdleCallback()
int32_t OH_ArkUI_PostIdleCallback(ArkUI_ContextHandle uiContext, void* userData,void (*callback)(uint64_t nanoTimeLeft, uint32_t frameCount, void* userData))
Description
Registers a callback function that will be executed after the rendering of the next frame is completed if there is more than 1 ms of idle time remaining before the next frame arrives. If the remaining time is less than 1 ms, the callback will be deferred until a subsequent frame where more than 1 ms of idle time is available. If there is no next frame scheduled, one will be automatically requested.
Since: 20
Parameters
| Name | Description |
|---|---|
| ArkUI_ContextHandle uiContext | UIContext object used to bind the instance. |
| void* userData | Pointer to the custom event parameter, which is passed in the callback when the custom callback is triggered. |
| callback | Custom callback function, which is executed when the remaining time until the next frame event exceeds 1 ms. |
| uint64_t nanoTimeLeft | Remaining time after the next frame is rendered. |
| uint32_t frameCount | Frame number. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_CAPI_INIT_ERROR if C API initialization failed. Returns ARKUI_ERROR_CODE_UI_CONTEXT_INVALID if the uiContext object is invalid. Returns ARKUI_ERROR_CODE_CALLBACK_INVALID if the callback function is invalid. |
OH_ArkUI_EnableEventPassthrough()
ArkUI_ErrorCode OH_ArkUI_EnableEventPassthrough(ArkUI_ContextHandle uiContext, bool enabled, ArkUI_RawInputEventType type)
Description
Enables or disables event passthrough. Event passthrough indicates that an event is directly delivered to a component without resampling during event distribution.
Since: 26.0.0
Parameters
| Name | Description |
|---|---|
| ArkUI_ContextHandle uiContext | UIContext object, which is used to bind an instance. |
| bool enabled | Whether to enable event passthrough. true to enable; false otherwise. |
| ArkUI_RawInputEventType type | Raw input event type (ArkUI_RawInputEventType) for enabling or disabling event passthrough. |
Return value
| Type | Description |
|---|---|
| ArkUI_ErrorCode | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if the UIContext object is invalid. |