openharmony 鸿蒙 capi-arkui-nativemodule-arkui-nativenodeapi-1

2026-08-25 浏览 (1)

ArkUI_NativeNodeAPI_1

typedef struct {...} ArkUI_NativeNodeAPI_1

Overview

Provides a collection of native-side Node type APIs provided by ArkUI. APIs related to the Node module must be called on the main thread.

Since: 12

Related module: ArkUI_NativeModule

Header file: native_node.h

Summary

Member Variables

NameDescription
int32_t versionStructure version, that is, the version number of the ArkUI_NativeNodeAPI_1 structure. The version number is provided by the system and does not need to be modified.

Member Functions

NameDescription
ArkUI_NodeHandle (*createNode)(ArkUI_NodeType type)Creates a component based on ArkUI_NodeType and returns the pointer to the component object.
void (*disposeNode)(ArkUI_NodeHandle node)Disposes of the component to which the specified pointer points.
int32_t (*addChild)(ArkUI_NodeHandle parent, ArkUI_NodeHandle child)Attaches a component to a parent node.
int32_t (*removeChild)(ArkUI_NodeHandle parent, ArkUI_NodeHandle child)Removes a component from its parent node.
int32_t (*insertChildAfter)(ArkUI_NodeHandle parent, ArkUI_NodeHandle child, ArkUI_NodeHandle sibling)Attaches a component to a parent node, with the position after the sibling node.
int32_t (*insertChildBefore)(ArkUI_NodeHandle parent, ArkUI_NodeHandle child, ArkUI_NodeHandle sibling)Attaches a component to a parent node, with the position before the sibling node.
int32_t (*insertChildAt)(ArkUI_NodeHandle parent, ArkUI_NodeHandle child, int32_t position)Attaches a component to a parent node, with the position specified by position.
int32_t (*setAttribute)(ArkUI_NodeHandle node, ArkUI_NodeAttributeType attribute, const ArkUI_AttributeItem* item)Sets component attributes.
const ArkUI_AttributeItem* (*getAttribute)(ArkUI_NodeHandle node, ArkUI_NodeAttributeType attribute)Obtains attributes. The pointer returned by this API is an internal buffer pointer of the ArkUI framework. As such, you do not need to call delete to free the memory. However, the pointer must be used before this API is called next time. Otherwise, the pointer may be overwritten by other values.
int32_t (*resetAttribute)(ArkUI_NodeHandle node, ArkUI_NodeAttributeType attribute)Resets component attributes.
int32_t (*registerNodeEvent)(ArkUI_NodeHandle node, ArkUI_NodeEventType eventType, int32_t targetId, void* userData)Registers an event for the specified node.
void (*unregisterNodeEvent)(ArkUI_NodeHandle node, ArkUI_NodeEventType eventType)Unregisters an event for the specified node.
void (*registerNodeEventReceiver)(void (*eventReceiver)(ArkUI_NodeEvent* event))Registers a unified entry point for event callbacks. The ArkUI framework collects component events generated during processing and returns them through the registered eventReceiver API.
Repeated calls will override the previously registered API. Avoid directly saving pointers to ArkUI_NodeEvent objects, as the data will be destroyed after the callback is complete.
To bind with a component instance, you can use the addNodeEventReceiver function.
void (*unregisterNodeEventReceiver)()Unregisters the unified entry point for event callbacks.
void (*markDirty)(ArkUI_NodeHandle node, ArkUI_NodeDirtyFlag dirtyFlag)Forcibly marks the current node for re-measurement, re-layout, or re-drawing. Regarding updates to system attributes, the ArkUI framework automatically marks nodes and re-executes measurement, layout, or drawing; you do not need to call this API actively.
uint32_t (*getTotalChildCount)(ArkUI_NodeHandle node)Obtains the number of child nodes.
ArkUI_NodeHandle (*getChildAt)(ArkUI_NodeHandle node, int32_t position)Obtains a child node.
ArkUI_NodeHandle (*getFirstChild)(ArkUI_NodeHandle node)Obtains the first child node.
ArkUI_NodeHandle (*getLastChild)(ArkUI_NodeHandle node)Obtains the last child node.
ArkUI_NodeHandle (*getPreviousSibling)(ArkUI_NodeHandle node)Obtains the previous sibling node.
ArkUI_NodeHandle (*getNextSibling)(ArkUI_NodeHandle node)Obtains the next sibling node.
int32_t (*registerNodeCustomEvent)(ArkUI_NodeHandle node, ArkUI_NodeCustomEventType eventType, int32_t targetId, void* userData)Registers a custom event for a node. Triggered events are returned through the custom event entry point function registered using registerNodeCustomEventReceiver.
void (*unregisterNodeCustomEvent)(ArkUI_NodeHandle node, ArkUI_NodeCustomEventType eventType)Unregisters a custom event for a node.
void (*registerNodeCustomEventReceiver)(void (*eventReceiver)(ArkUI_NodeCustomEvent* event))Registers a unified entry point for custom node event callbacks. The ArkUI framework collects custom component events generated during processing and returns them through the custom event entry point function registered using registerNodeCustomEventReceiver.
Repeated calls will override the previously registered API.
Do not directly save the ArkUI_NodeCustomEvent object pointer. The data will be destroyed after the callback is complete.
To bind with a component instance, you can use the addNodeCustomEventReceiver function.
void (*unregisterNodeCustomEventReceiver)()Unregisters the unified entry point function for custom node event callbacks.
int32_t (*setMeasuredSize)(ArkUI_NodeHandle node, int32_t width, int32_t height)Sets the width and height for a component after the measurement in the measurement callback function.
int32_t (*setLayoutPosition)(ArkUI_NodeHandle node, int32_t positionX, int32_t positionY)Sets the position of a component in the layout callback function.
ArkUI_IntSize (*getMeasuredSize)(ArkUI_NodeHandle node)Obtains the width and height of a component after measurement.
ArkUI_IntOffset (*getLayoutPosition)(ArkUI_NodeHandle node)Obtains the offset of a node relative to its parent node after component layout is completed. The unit is px. The offset is the result after the parent container lays out the node. Therefore, the offset attribute that takes effect after the layout and the position attribute that does not participate in the layout do not affect the offset value.
int32_t (*measureNode)(ArkUI_NodeHandle node, ArkUI_LayoutConstraint* Constraint)Measures a node. You can use the getMeasuredSize API to obtain the size after the measurement.
int32_t (*layoutNode)(ArkUI_NodeHandle node, int32_t positionX, int32_t positionY)Lays outs a node and specifies the expected position of the node relative to its parent node.
int32_t (*addNodeEventReceiver)(ArkUI_NodeHandle node, void (*eventReceiver)(ArkUI_NodeEvent* event))Adds a component event callback function to a component to receive component events generated by it. Unlike the global registration function registerNodeEventReceiver, this API allows multiple event receivers to be added to the same component.
The callback added by this function is triggered before the global callback registered by registerNodeEventReceiver.
Avoid directly saving pointers to ArkUI_NodeEvent objects, as the data will be destroyed after the callback is complete.
int32_t (*removeNodeEventReceiver)(ArkUI_NodeHandle node, void (*eventReceiver)(ArkUI_NodeEvent* event))Removes a registered component event callback function from a component.
int32_t (*addNodeCustomEventReceiver)(ArkUI_NodeHandle node, void (*eventReceiver)(ArkUI_NodeCustomEvent* event))Adds a custom event callback function to a component to receive custom events (such as layout and drawing events) generated by it. Unlike the global registration function registerNodeCustomEventReceiver, this API allows multiple event receivers to be added to the same component.
The callback added by this function is triggered before the global callback registered by registerNodeCustomEventReceiver.
Do not directly save the ArkUI_NodeCustomEvent object pointer. The data will be destroyed after the callback is complete.
int32_t (*removeNodeCustomEventReceiver)(ArkUI_NodeHandle node, void (*eventReceiver)(ArkUI_NodeCustomEvent* event))Removes a registered custom event callback function from a component.
int32_t (*setUserData)(ArkUI_NodeHandle node, void* userData)Saves custom data on a component.
void* (*getUserData)(ArkUI_NodeHandle node)Obtains the custom data stored on a component.
int32_t (*setLengthMetricUnit)(ArkUI_NodeHandle node, ArkUI_LengthMetricUnit unit)Sets the unit of measurement for a component.
ArkUI_NodeHandle (*getParent)(ArkUI_NodeHandle node)Obtains the parent node.
int32_t (*removeAllChildren)(ArkUI_NodeHandle parent)Removes all child nodes from the parent component.

Member Function Description

createNode()

ArkUI_NodeHandle (*createNode)(ArkUI_NodeType type)

Description

Creates a component based on ArkUI_NodeType and returns the pointer to the component object.

Since: 12

Parameters

NameDescription
ArkUI_NodeType typeType of the component to create.

Return value

TypeDescription
ArkUI_NodeHandlePointer to the created component. If the component fails to be created, NULL is returned. You need to manage the lifecycle of the returned component object pointer. Otherwise, issues such as Use After Free may cause process crashes or memory leaks.

disposeNode()

void (*disposeNode)(ArkUI_NodeHandle node)

Description

Disposes of the component to which the specified pointer points. When calling this API on a non-main thread, special attention must be paid to the lifecycle of the component object to be destroyed. Improper lifecycle management may cause the application to crash; therefore, it is not recommended to call this API on non-main threads.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodePointer to a component object.

addChild()

int32_t (*addChild)(ArkUI_NodeHandle parent, ArkUI_NodeHandle child)

Description

Attaches a component to a parent node. This API is used for node operations, and you are advised to call this API in the main thread.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle parentPointer to the parent node.
ArkUI_NodeHandle childPointer to the child node.

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.
Returns ARKUI_ERROR_CODE_NOT_SUPPROTED_FOR_ARKTS_NODE if the operation is not supported for the node created in ArkTS.
Returns ARKUI_ERROR_CODE_NODE_IS_ADOPTED if the node has been adopted as an affiliated node. This specification is supported since API version 22.

removeChild()

int32_t (*removeChild)(ArkUI_NodeHandle parent, ArkUI_NodeHandle child)

Description

Removes a component from its parent node. This API is used for node operations, and you are advised to call this API in the main thread.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle parentPointer to the parent node.
ArkUI_NodeHandle childPointer to the child node.

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.
Returns ARKUI_ERROR_CODE_NOT_SUPPROTED_FOR_ARKTS_NODE if the operation is not supported for the node created in ArkTS.

insertChildAfter()

int32_t (*insertChildAfter)(ArkUI_NodeHandle parent, ArkUI_NodeHandle child, ArkUI_NodeHandle sibling)

Description

Attaches a component to a parent node, with the position after the sibling node. This API is used for node operations, and you are advised to call this API in the main thread.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle parentPointer to the parent node.
ArkUI_NodeHandle childPointer to the child node.
ArkUI_NodeHandle siblingPointer to the sibling node after which the target node is to be inserted. If the value is null, the node is inserted at the end of the parent node.

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.
Returns ARKUI_ERROR_CODE_NOT_SUPPROTED_FOR_ARKTS_NODE if the operation is not supported for the node created in ArkTS.
Returns ARKUI_ERROR_CODE_NODE_IS_ADOPTED if the node has been adopted as an affiliated node. This specification is supported since API version 22.

insertChildBefore()

int32_t (*insertChildBefore)(ArkUI_NodeHandle parent, ArkUI_NodeHandle child, ArkUI_NodeHandle sibling)

Description

Attaches a component to a parent node, with the position before the sibling node. This API is used for node operations, and you are advised to call this API in the main thread.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle parentPointer to the parent node.
ArkUI_NodeHandle childPointer to the child node.
ArkUI_NodeHandle siblingPointer to the sibling node before which the target node is to be inserted. If the value is null, the node is inserted at the end of the parent node.

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.
Returns ARKUI_ERROR_CODE_NOT_SUPPROTED_FOR_ARKTS_NODE if the operation is not supported for the node created in ArkTS.
Returns ARKUI_ERROR_CODE_NODE_IS_ADOPTED if the node has been adopted as an affiliated node. This specification is supported since API version 22.

insertChildAt()

int32_t (*insertChildAt)(ArkUI_NodeHandle parent, ArkUI_NodeHandle child, int32_t position)

Description

Attaches a component to a parent node, with the position specified by position. This API is used for node operations, and you are advised to call this API in the main thread.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle parentPointer to the parent node.
ArkUI_NodeHandle childPointer to the child node.
int32_t positionInserting position. The value range is [-2147483648, 2147483647]. If the value is a negative number or invalid, the component is inserted at the end of the parent node.

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.
Returns ARKUI_ERROR_CODE_NOT_SUPPROTED_FOR_ARKTS_NODE if the operation is not supported for the node created in ArkTS.
Returns ARKUI_ERROR_CODE_NODE_IS_ADOPTED if the node has been adopted as an affiliated node. This specification is supported since API version 22.

setAttribute()

int32_t (*setAttribute)(ArkUI_NodeHandle node, ArkUI_NodeAttributeType attribute, const ArkUI_AttributeItem* item)

Description

Sets attributes. You are advised to call this API in the main thread.

In actual service scenarios, if the attributes set for a component contain the heap memory you apply for, ensure that the component is no longer used before calling the corresponding release API. For example, NODE_TEXT_CONTENT_WITH_STYLED_STRING in ArkUI_NodeAttributeType.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeNode whose attribute needs to be set.
ArkUI_NodeAttributeType attributeType of attribute to set.
const ArkUI_AttributeItem* itemAttribute value to set.

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.
Returns ARKUI_ERROR_CODE_ATTRIBUTE_OR_EVENT_NOT_SUPPORTED if the attribute is not supported.
Returns ARKUI_ERROR_CODE_NOT_SUPPROTED_FOR_ARKTS_NODE if the operation is not supported for the node created in ArkTS.
Returns ERROR_CODE_NATIVE_IMPL_NODE_ADAPTER_EXIST if NodeAdapter already exists.

getAttribute()

const ArkUI_AttributeItem* (*getAttribute)(ArkUI_NodeHandle node, ArkUI_NodeAttributeType attribute)

Description

Obtains attributes. The pointer returned by this API is an internal buffer pointer of the ArkUI framework. As such, you do not need to call delete to free the memory. However, the pointer must be used before this API is called next time. Otherwise, the pointer may be overwritten by other values.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeNode whose attribute needs to be obtained.
ArkUI_NodeAttributeType attributeType of the attribute to obtain.

Return value

TypeDescription
const ArkUI_AttributeItem*Attribute value. If the operation fails, a null pointer is returned.

resetAttribute()

int32_t (*resetAttribute)(ArkUI_NodeHandle node, ArkUI_NodeAttributeType attribute)

Description

Resets attributes. You are advised to call this API in the main thread.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeNode whose attribute needs to be reset.
ArkUI_NodeAttributeType attributeType of the attribute to reset.

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.
Returns ARKUI_ERROR_CODE_ATTRIBUTE_OR_EVENT_NOT_SUPPORTED if the attribute is not supported.
Returns ARKUI_ERROR_CODE_NOT_SUPPROTED_FOR_ARKTS_NODE if the operation is not supported for the node created in ArkTS.

registerNodeEvent()

int32_t (*registerNodeEvent)(ArkUI_NodeHandle node, ArkUI_NodeEventType eventType, int32_t targetId, void* userData)

Description

Registers an event for the specified node.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget node.
ArkUI_NodeEventType eventTypeType of the event to register.
int32_t targetIdCustom event ID, which is passed in the callback of ArkUI_NodeEvent when the event is triggered.
void* userDataCustom event parameter, which is passed in the callback of ArkUI_NodeEvent when the event is triggered.

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.
Returns ARKUI_ERROR_CODE_ATTRIBUTE_OR_EVENT_NOT_SUPPORTED if the event is not supported.
Returns ARKUI_ERROR_CODE_NOT_SUPPROTED_FOR_ARKTS_NODE if the operation is not supported for the node created in ArkTS.

unregisterNodeEvent()

void (*unregisterNodeEvent)(ArkUI_NodeHandle node, ArkUI_NodeEventType eventType)

Description

Unregisters an event for the specified node.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget node.
ArkUI_NodeEventType eventTypeType of the event to unregister.

registerNodeEventReceiver()

void (*registerNodeEventReceiver)(void (*eventReceiver)(ArkUI_NodeEvent* event))

Description

Registers a unified entry point for event callbacks. The ArkUI framework collects component events generated during processing and returns them through the registered eventReceiver API.
Repeated calls will override the previously registered API. Do not directly save the pointer to the ArkUI_NodeEvent object. The data will be destroyed after the callback is complete.
To bind with a component instance, you can use the addNodeEventReceiver API.

Since: 12

Parameters

NameDescription
void (*eventReceiver)(ArkUI_NodeEvent* event)Unified entry point for event callbacks to register.

unregisterNodeEventReceiver()

void (*unregisterNodeEventReceiver)()

Description

Unregisters the unified entry point for event callbacks.

Since: 12

markDirty()

void (*markDirty)(ArkUI_NodeHandle node, ArkUI_NodeDirtyFlag dirtyFlag)

Description

Forcibly marks the current node for re-measurement, re-layout, or re-drawing. Regarding updates to system attributes, the ArkUI framework automatically marks nodes and re-executes measurement, layout, or drawing; you do not need to call this API actively.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeNode object that needs to be marked for re-measurement, re-layout, or re-drawing.
ArkUI_NodeDirtyFlag dirtyFlagType for re-measurement, re-layout, or re-drawing.

getTotalChildCount()

uint32_t (*getTotalChildCount)(ArkUI_NodeHandle node)

Description

Obtains the number of child nodes.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget node.

Return value

TypeDescription
uint32_tReturns the number of child nodes; returns 0 if there is no child node.

getChildAt()

ArkUI_NodeHandle (*getChildAt)(ArkUI_NodeHandle node, int32_t position)

Description

Obtains a child node.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget node.
int32_t positionPosition of the child node.

Return value

TypeDescription
ArkUI_NodeHandlePointer to the node, or NULL if the node is not found.

getFirstChild()

ArkUI_NodeHandle (*getFirstChild)(ArkUI_NodeHandle node)

Description

Obtains the first child node.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget node.

Return value

TypeDescription
ArkUI_NodeHandlePointer to the node, or NULL if the node is not found.

getLastChild()

ArkUI_NodeHandle (*getLastChild)(ArkUI_NodeHandle node)

Description

Obtains the last child node.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget node.

Return value

TypeDescription
ArkUI_NodeHandlePointer to the node, or NULL if the node is not found.

getPreviousSibling()

ArkUI_NodeHandle (*getPreviousSibling)(ArkUI_NodeHandle node)

Description

Obtains the previous sibling node.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget node.

Return value

TypeDescription
ArkUI_NodeHandlePointer to the node, or NULL if the node is not found.

getNextSibling()

ArkUI_NodeHandle (*getNextSibling)(ArkUI_NodeHandle node)

Description

Obtains the next sibling node.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget node.

Return value

TypeDescription
ArkUI_NodeHandlePointer to the node, or NULL if the node is not found.

registerNodeCustomEvent()

int32_t (*registerNodeCustomEvent)(ArkUI_NodeHandle node, ArkUI_NodeCustomEventType eventType, int32_t targetId, void* userData)

Description

Registers a custom event for a node. Triggered events are returned through the custom event entry point function registered using registerNodeCustomEventReceiver.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget node.
ArkUI_NodeCustomEventType eventTypeType of the event to register.
int32_t targetIdCustom event ID, which is passed in the callback of ArkUI_NodeCustomEvent when the event is triggered.
void* userDataCustom event parameter, which is passed in the callback of ArkUI_NodeCustomEvent when the event is triggered.

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.
Returns ARKUI_ERROR_CODE_ATTRIBUTE_OR_EVENT_NOT_SUPPORTED if the event is not supported.

unregisterNodeCustomEvent()

void (*unregisterNodeCustomEvent)(ArkUI_NodeHandle node, ArkUI_NodeCustomEventType eventType)

Description

Unregisters a custom event for a node.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget node.
ArkUI_NodeCustomEventType eventTypeType of the event to unregister.

registerNodeCustomEventReceiver()

void (*registerNodeCustomEventReceiver)(void (*eventReceiver)(ArkUI_NodeCustomEvent* event))

Description

Registers a unified entry point for custom node event callbacks. The ArkUI framework collects custom component events generated during processing and returns them through the custom event entry point function registered using registerNodeCustomEventReceiver.
Repeated calls will override the previously registered API.
Do not directly save the pointer to the ArkUI_NodeCustomEvent object. The data will be destroyed after the callback is complete.
To bind with a component instance, you can use the addNodeCustomEventReceiver function.

Since: 12

Parameters

NameDescription
void (*eventReceiver)(ArkUI_NodeCustomEvent* event)Unified entry point for event callbacks to register.

unregisterNodeCustomEventReceiver()

void (*unregisterNodeCustomEventReceiver)()

Description

Unregisters the unified entry point function for custom node event callbacks.

Since: 12

setMeasuredSize()

int32_t (*setMeasuredSize)(ArkUI_NodeHandle node, int32_t width, int32_t height)

Description

Sets the width and height for a component after the measurement in the measurement callback function.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget node.
int32_t widthWidth to set.
int32_t heightHeight to set.

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.

setLayoutPosition()

int32_t (*setLayoutPosition)(ArkUI_NodeHandle node, int32_t positionX, int32_t positionY)

Description

Sets the position of a component in the layout callback function. This API has a lower priority than NODE_POSITION.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget node.
int32_t positionXX-coordinate.
int32_t positionYY-coordinate.

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.

getMeasuredSize()

ArkUI_IntSize (*getMeasuredSize)(ArkUI_NodeHandle node)

Description

Obtains the width and height of a component after measurement.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget node.

Return value

TypeDescription
ArkUI_IntSizeWidth and height of the component, wrapped in an ArkUI_IntSize structure.

getLayoutPosition()

ArkUI_IntOffset (*getLayoutPosition)(ArkUI_NodeHandle node)

Description

Obtains the offset of a node relative to its parent node after component layout is completed. The unit is px. The offset is the result after the parent container lays out the node. Therefore, the offset attribute that takes effect after the layout and the position attribute that does not participate in the layout do not affect the offset value.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget node.

Return value

TypeDescription
ArkUI_IntOffsetPosition of the component, wrapped in an ArkUI_IntOffset structure.

measureNode()

int32_t (*measureNode)(ArkUI_NodeHandle node, ArkUI_LayoutConstraint* Constraint)

Description

Measures a node. You can use the getMeasuredSize API to obtain the size after the measurement.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget node.
ArkUI_LayoutConstraint* ConstraintSize constraint.

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.

layoutNode()

int32_t (*layoutNode)(ArkUI_NodeHandle node, int32_t positionX, int32_t positionY)

Description

Lays outs a node and specifies the expected position of the node relative to its parent node.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget node.
int32_t positionXX-coordinate.
int32_t positionYY-coordinate.

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.

addNodeEventReceiver()

int32_t (*addNodeEventReceiver)(ArkUI_NodeHandle node, void (*eventReceiver)(ArkUI_NodeEvent* event))

Description

Adds a component event callback function to a component to receive component events generated by it. Unlike the global registration function registerNodeEventReceiver, this API allows multiple event receivers to be added to the same component.
The callback added by this function is triggered before the global callback registered by registerNodeEventReceiver.
Do not directly save the pointer to the ArkUI_NodeEvent object. The data will be destroyed after the callback is complete.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeComponent for which you want to add the event callback function.
void (*eventReceiver)(ArkUI_NodeEvent* event)Event callback for the component.

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.

removeNodeEventReceiver()

int32_t (*removeNodeEventReceiver)(ArkUI_NodeHandle node, void (*eventReceiver)(ArkUI_NodeEvent* event))

Description

Removes a registered component event callback function from a component.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeComponent for which you want to remove the event callback function.
void (eventReceiver)(ArkUI_NodeEvent event)Component event callback function to remove.

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.

addNodeCustomEventReceiver()

int32_t (*addNodeCustomEventReceiver)(ArkUI_NodeHandle node, void (*eventReceiver)(ArkUI_NodeCustomEvent* event))

Description

Adds a custom event callback function to a component to receive custom events (such as layout and drawing events) generated by it. Unlike the global registration function registerNodeCustomEventReceiver, this API allows multiple event receivers to be added to the same component.
The callback added by this function is triggered before the global callback registered by registerNodeCustomEventReceiver.
Do not directly save the pointer to the ArkUI_NodeCustomEvent object. The data will be destroyed after the callback is complete.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeComponent for which you want to add the custom event callback function.
void (*eventReceiver)(ArkUI_NodeCustomEvent* event)Custom event callback for the component.

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.

removeNodeCustomEventReceiver()

int32_t (*removeNodeCustomEventReceiver)(ArkUI_NodeHandle node, void (*eventReceiver)(ArkUI_NodeCustomEvent* event))

Description

Removes a registered custom event callback function from a component.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeComponent for which you want to remove the custom event callback function.
void (*eventReceiver)(ArkUI_NodeCustomEvent* event)Custom event callback function to remove.

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.

setUserData()

int32_t (*setUserData)(ArkUI_NodeHandle node, void* userData)

Description

Saves custom data on a component.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeComponent on which the custom data will be saved.
void* userDataCustom data to be saved.

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.

getUserData()

void* (*getUserData)(ArkUI_NodeHandle node)

Description

Obtains the custom data stored on a component.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget component.

Return value

TypeDescription
void*Custom data.

setLengthMetricUnit()

int32_t (*setLengthMetricUnit)(ArkUI_NodeHandle node, ArkUI_LengthMetricUnit unit)

Description

Sets the unit of measurement for a component.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeComponent for which you want to set the unit.
ArkUI_LengthMetricUnit unitUnit type ArkUI_LengthMetricUnit. The default value is ARKUI_LENGTH_METRIC_UNIT_DEFAULT.

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.

getParent()

ArkUI_NodeHandle (*getParent)(ArkUI_NodeHandle node)

Description

Obtains the parent node.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle nodeTarget node.

Return value

TypeDescription
ArkUI_NodeHandlePointer to the node, or NULL if the node is not found.

removeAllChildren()

int32_t (*removeAllChildren)(ArkUI_NodeHandle parent)

Description

Removes all child nodes from the parent component.

Since: 12

Parameters

NameDescription
ArkUI_NodeHandle parentTarget node.

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.

你可能感兴趣的鸿蒙文章

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/mG7SfeUZ