openharmony 鸿蒙 capi-native-node-napi-h

2026-08-25 浏览 (1)

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

NameDescription
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

NameDescription
napi_env envPointer to the Node-API environment.
napi_value frameNodeFrameNode object created on the ArkTS side.
ArkUI_NodeHandle* handlePointer to the ArkUI_NodeHandle.

Return value

TypeDescription
int32_tResult 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

NameDescription
napi_env envPointer to the Node-API environment.
napi_value valueUIContext object created on the ArkTS side.
ArkUI_ContextHandle* contextPointer to the ArkUI_ContextHandle.

Return value

TypeDescription
int32_tResult 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

NameDescription
napi_env envPointer to the Node-API environment.
napi_value valueNodeContent object created on the ArkTS side.
ArkUI_NodeContentHandle* contentPointer to the ArkUI_NodeContentHandle.

Return value

TypeDescription
int32_tResult 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

NameDescription
napi_env envPointer to the Node-API environment.
napi_value valueDrawableDescriptor object created on the ArkTS side.
ArkUI_DrawableDescriptor** drawableDescriptorDouble pointer used to receive the ArkUI_DrawableDescriptor object.

Return value

TypeDescription
int32_tResult 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

NameDescription
napi_env envPointer to the Node-API environment.
napi_value value$r resource object created on the ArkTS side.
ArkUI_DrawableDescriptor** drawableDescriptorDouble pointer used to receive the ArkUI_DrawableDescriptor object.

Return value

TypeDescription
int32_tResult 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

NameDescription
ArkUI_NodeHandle nodeTarget node.
char* bufferPointer to the buffer to which the obtained ID is written.
int32_t bufferSizeBuffer size.
int32_t* writeLengthPointer 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

TypeDescription
ArkUI_ErrorCodeResult 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

NameDescription
ArkUI_NodeHandle nodeTarget node.
char* bufferPointer to the buffer to which the obtained name is written.
int32_t bufferSizeBuffer size.
int32_t* writeLengthPointer 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

TypeDescription
ArkUI_ErrorCodeResult 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

NameDescription
ArkUI_NodeHandle nodeTarget node.
int32_t* lengthPointer to the length of the navigation stack. The result, if obtained successfully, is written back to this parameter.

Return value

TypeDescription
ArkUI_ErrorCodeResult 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

NameDescription
ArkUI_NodeHandle nodeTarget node.
int32_t indexIndex of the target page in the navigation stack.
char* bufferPointer to the buffer to which the obtained name is written.
int32_t bufferSizeBuffer size.
int32_t* writeLengthPointer 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

TypeDescription
ArkUI_ErrorCodeResult 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

NameDescription
ArkUI_NodeHandle nodeTarget node.
char* bufferPointer to the buffer to which the obtained ID is written.
int32_t bufferSizeBuffer size.
int32_t* writeLengthPointer 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

TypeDescription
ArkUI_ErrorCodeResult 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

NameDescription
ArkUI_NodeHandle nodeTarget node.
ArkUI_NavDestinationState* statePointer to the state of the NavDestination component. The result, if obtained successfully, is written back to this parameter.

Return value

TypeDescription
ArkUI_ErrorCodeResult 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

NameDescription
ArkUI_NodeHandle nodeTarget node.
int32_t* indexPointer to the zero-based index.

Return value

TypeDescription
ArkUI_ErrorCodeResult 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

NameDescription
ArkUI_NodeHandle nodeTarget node.

Return value

TypeDescription
napi_valueParameter 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

NameDescription
ArkUI_NodeHandle nodeTarget node.
int32_t* indexPointer to the one-based index.

Return value

TypeDescription
ArkUI_ErrorCodeResult 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

NameDescription
ArkUI_NodeHandle nodeTarget node.
char* bufferPointer to the buffer to which the obtained name is written.
int32_t bufferSizeBuffer size.
int32_t* writeLengthPointer 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

TypeDescription
ArkUI_ErrorCodeResult 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

NameDescription
ArkUI_NodeHandle nodeTarget node.
char* bufferPointer to the buffer to which the page path is written.
int32_t bufferSizeBuffer size.
int32_t* writeLengthPointer 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

TypeDescription
ArkUI_ErrorCodeResult 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

NameDescription
ArkUI_NodeHandle nodeTarget node.
ArkUI_RouterPageState* statePointer to the status of the Router page. The result, if obtained successfully, is written back to this parameter.

Return value

TypeDescription
ArkUI_ErrorCodeResult 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

NameDescription
ArkUI_NodeHandle nodeTarget node.
char* bufferPointer to the buffer to which the page ID is written.
int32_t bufferSizeBuffer size.
int32_t* writeLengthPointer 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

TypeDescription
ArkUI_ErrorCodeResult 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

NameDescription
napi_env envPointer to the Node-API environment.

Return value

TypeDescription
ArkUI_ErrorCodeResult 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

NameDescription
napi_env envPointer 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

NameDescription
ArkUI_ContextHandle uiContextPointer to the UIContext object, which is used to bind an instance.
void* userDataPointer to the custom event parameter, which is passed in the callback when the event is triggered.
callbackCustom callback function.
uint64_t nanoTimestampTimestamp of the frame signal.
uint32_t frameCountFrame number.

Return value

TypeDescription
int32_tResult 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

NameDescription
ArkUI_ContextHandle uiContextUIContext object used to bind the instance.
void* userDataPointer to the custom event parameter, which is passed in the callback when the custom callback is triggered.
callbackCustom callback function, which is executed when the remaining time until the next frame event exceeds 1 ms.
uint64_t nanoTimeLeftRemaining time after the next frame is rendered.
uint32_t frameCountFrame number.

Return value

TypeDescription
int32_tResult 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

NameDescription
ArkUI_ContextHandle uiContextUIContext object, which is used to bind an instance.
bool enabledWhether to enable event passthrough. true to enable; false otherwise.
ArkUI_RawInputEventType typeRaw input event type (ArkUI_RawInputEventType) for enabling or disabling event passthrough.

Return value

TypeDescription
ArkUI_ErrorCodeResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_PARAM_INVALID if the UIContext object is invalid.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 arkts-apis-uicontext-contextmenucontroller

openharmony 鸿蒙 errorcode-canvas

openharmony 鸿蒙 capi-oh-nativexcomponent-native-xcomponent-oh-nativexcomponent

openharmony 鸿蒙 errorcode-bindSheet

openharmony 鸿蒙 js-apis-arkui-uiExtension-sys

openharmony 鸿蒙 capi-arkui-accessibility-arkui-accessibilityeventinfo

openharmony 鸿蒙 capi-arkui-rendernodeutils

openharmony 鸿蒙 js-apis-arkui-node

openharmony 鸿蒙 capi-native-node-h

openharmony 鸿蒙 capi-arkui-nativemodule-arkui-listitemswipeactionitem

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/gptFL4lm