native_interface_xcomponent.h
Overview
Declares the APIs for accessing Native XComponent features.
File to include: <ace/xcomponent/native_interface_xcomponent.h>
Library: libace_ndk.z.so
System capability: SystemCapability.ArkUI.ArkUI.Full
Since: 8
Related module: OH_NativeXComponent Native XComponent
Sample: NativeXComponentSample
Summary
Structs
| Name | typedef Keyword | Description |
|---|---|---|
| OH_NativeXComponent_HistoricalPoint | OH_NativeXComponent_HistoricalPoint | Represents a historical touch point. |
| OH_NativeXComponent_TouchPoint | OH_NativeXComponent_TouchPoint | Describes the touch point of the touch event. |
| OH_NativeXComponent_TouchEvent | OH_NativeXComponent_TouchEvent | Describes the touch event. |
| OH_NativeXComponent_MouseEvent | OH_NativeXComponent_MouseEvent | Describes the mouse event. |
| OH_NativeXComponent_Callback | OH_NativeXComponent_Callback | Registers callbacks for the surface lifecycle and touch event. |
| OH_NativeXComponent_MouseEvent_Callback | OH_NativeXComponent_MouseEvent_Callback | Registers callbacks for the mouse event. |
| OH_NativeXComponent_ExpectedRateRange | OH_NativeXComponent_ExpectedRateRange | Defines the expected frame rate range. |
| OH_NativeXComponent | OH_NativeXComponent | Provides an encapsulated OH_NativeXComponent instance. |
| OH_NativeXComponent_KeyEvent | OH_NativeXComponent_KeyEvent | Provides an encapsulated OH_NativeXComponent_KeyEvent instance. |
| OH_NativeXComponent_ExtraMouseEventInfo | OH_NativeXComponent_ExtraMouseEventInfo | Provides an encapsulated instance of extended mouse event information. |
| OH_ArkUI_SurfaceHolder | OH_ArkUI_SurfaceHolder | Provides an encapsulated OH_ArkUI_SurfaceHolder instance. |
| OH_ArkUI_SurfaceCallback | OH_ArkUI_SurfaceCallback | Defines surface lifecycle callback functions. |
| NativeWindow | OHNativeWindow | Provides an encapsulated NativeWindow instance. |
| ArkUI_XComponentSurfaceConfig | ArkUI_XComponentSurfaceConfig | Defines the surface configuration for the XComponent, which specifies whether the XComponent's surface should be treated as opaque during rendering. |
Enums
| Name | typedef Keyword | Description |
|---|---|---|
| anonymous | - | Enumerates the API access states. |
| ArkUI_XComponent_ImageAnalyzerState | ArkUI_XComponent_ImageAnalyzerState | Enumerates the AI image analyzer error codes of the XComponent. |
| OH_NativeXComponent_TouchEventType | OH_NativeXComponent_TouchEventType | Enumerates the touch event types. |
| OH_NativeXComponent_TouchPointToolType | OH_NativeXComponent_TouchPointToolType | Enumerates the touch point tool types. |
| OH_NativeXComponent_EventSourceType | OH_NativeXComponent_EventSourceType | Enumerates the touch event source types. |
| OH_NativeXComponent_MouseEventAction | OH_NativeXComponent_MouseEventAction | Enumerates the mouse event actions. |
| OH_NativeXComponent_MouseEventButton | OH_NativeXComponent_MouseEventButton | Enumerates the mouse event buttons. |
| OH_NativeXComponent_TouchEvent_SourceTool | OH_NativeXComponent_TouchEvent_SourceTool | Enumerates the source tool types of touch events. |
Macros
| Name | Description |
|---|---|
| OH_NATIVE_XCOMPONENT_OBJ ("__NATIVE_XCOMPONENT_OBJ__") | Native XComponent instance. |
| OH_NATIVE_XCOMPONENT_MAX_TOUCH_POINTS_NUMBER 10 | Maximum number of identifiable touch points in a touch event. |
Functions
Variables
| Name | Description |
|---|---|
| const uint32_t OH_XCOMPONENT_ID_LEN_MAX = 128 | Maximum length of the ArkUI XComponent ID. Since: 8 |
| const uint32_t OH_MAX_TOUCH_POINTS_NUMBER = 10 | Maximum number of identifiable touch points in a touch event. Since: 8 |
| OH_NATIVE_XCOMPONENT_MAX_TOUCH_POINTS_NUMBER 10 | Maximum number of supported touch points. Since: 8 |
Enum Description
anonymous
enum anonymous
Description
Enumerates the API access states.
Since: 8
| Value | Description |
|---|---|
| OH_NATIVEXCOMPONENT_RESULT_SUCCESS = 0 | Success. |
| OH_NATIVEXCOMPONENT_RESULT_FAILED = -1 | Failure. |
| OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER = -2 | Invalid parameter. |
ArkUI_XComponent_ImageAnalyzerState
enum ArkUI_XComponent_ImageAnalyzerState
Description
Enumerates the AI image analyzer error codes of the XComponent.
Since: 18
| Value | Description |
|---|---|
| ARKUI_XCOMPONENT_AI_ANALYSIS_FINISHED = 0 | AI image analysis is complete. |
| ARKUI_XCOMPONENT_AI_ANALYSIS_DISABLED = 110000 | AI image analysis is disabled. |
| ARKUI_XCOMPONENT_AI_ANALYSIS_UNSUPPORTED = 110001 | The device does not support AI image analysis. |
| ARKUI_XCOMPONENT_AI_ANALYSIS_ONGOING = 110002 | AI image analysis is in progress. |
| ARKUI_XCOMPONENT_AI_ANALYSIS_STOPPED = 110003 | AI image analysis has been stopped. |
OH_NativeXComponent_TouchEventType
enum OH_NativeXComponent_TouchEventType
Description
Enumerates the touch event types.
Since: 8
| Value | Description |
|---|---|
| OH_NATIVEXCOMPONENT_DOWN = 0 | The touch event is triggered when a finger is pressed. |
| OH_NATIVEXCOMPONENT_UP = 1 | The touch event is triggered when a finger is lifted. |
| OH_NATIVEXCOMPONENT_MOVE = 2 | The touch event is triggered when a finger is moved on the screen. |
| OH_NATIVEXCOMPONENT_CANCEL = 3 | The event is triggered when a touch event is canceled. |
| OH_NATIVEXCOMPONENT_UNKNOWN = 4 | Invalid touch type. |
OH_NativeXComponent_TouchPointToolType
enum OH_NativeXComponent_TouchPointToolType
Description
Enumerates the touch point tool types.
Since: 9
| Value | Description |
|---|---|
| OH_NATIVEXCOMPONENT_TOOL_TYPE_UNKNOWN = 0 | Unknown tool type. |
| OH_NATIVEXCOMPONENT_TOOL_TYPE_FINGER = 1 | Finger. |
| OH_NATIVEXCOMPONENT_TOOL_TYPE_PEN = 2 | Stylus. |
| OH_NATIVEXCOMPONENT_TOOL_TYPE_RUBBER = 3 | Rubber. |
| OH_NATIVEXCOMPONENT_TOOL_TYPE_BRUSH = 4 | Brush. |
| OH_NATIVEXCOMPONENT_TOOL_TYPE_PENCIL = 5 | Pencil. |
| OH_NATIVEXCOMPONENT_TOOL_TYPE_AIRBRUSH = 6 | Air brush. |
| OH_NATIVEXCOMPONENT_TOOL_TYPE_MOUSE = 7 | Mouse. |
| OH_NATIVEXCOMPONENT_TOOL_TYPE_LENS = 8 | Lens. |
OH_NativeXComponent_EventSourceType
enum OH_NativeXComponent_EventSourceType
Description
Enumerates the touch event source types.
Since: 9
| Value | Description |
|---|---|
| OH_NATIVEXCOMPONENT_SOURCE_TYPE_UNKNOWN = 0 | Unknown source type. |
| OH_NATIVEXCOMPONENT_SOURCE_TYPE_MOUSE = 1 | Source that generates a mouse multi-click event. |
| OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHSCREEN = 2 | Source that generates a touchscreen multitouch event. |
| OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHPAD = 3 | Source that generates a touchpad multitouch event. |
| OH_NATIVEXCOMPONENT_SOURCE_TYPE_JOYSTICK = 4 | Source that generates a joystick multitouch event. |
| OH_NATIVEXCOMPONENT_SOURCE_TYPE_KEYBOARD = 5 | Source that generates a key event. Since: 10 |
OH_NativeXComponent_MouseEventAction
enum OH_NativeXComponent_MouseEventAction
Description
Enumerates the mouse event actions.
Since: 9
| Value | Description |
|---|---|
| OH_NATIVEXCOMPONENT_MOUSE_NONE = 0 | Invalid mouse event. |
| OH_NATIVEXCOMPONENT_MOUSE_PRESS = 1 | Mouse button press. |
| OH_NATIVEXCOMPONENT_MOUSE_RELEASE = 2 | Mouse button release. |
| OH_NATIVEXCOMPONENT_MOUSE_MOVE = 3 | Mouse movement. |
| OH_NATIVEXCOMPONENT_MOUSE_CANCEL = 4 | Mouse button canceling. Since: 18 Note: Mouse button canceling is typically triggered in the following scenarios: 1. Component focus loss: A currently focused XComponent loses focus due to a system event (such as pop-up interruption or app switching). 2. Event interruption: During a mouse operation, a higher-priority event occurs (such as a system-level gesture or forced event stream recycling), causing the current mouse operation to be forcibly terminated. 3. Abnormal state exit: In scenarios such as component destruction or abnormal rendering environment, unfinished mouse events are marked as canceled. |
OH_NativeXComponent_MouseEventButton
enum OH_NativeXComponent_MouseEventButton
Description
Enumerates the mouse event buttons.
Since: 9
| Value | Description |
|---|---|
| OH_NATIVEXCOMPONENT_NONE_BUTTON = 0 | No button. |
| OH_NATIVEXCOMPONENT_LEFT_BUTTON = 0x01 | Left mouse button. |
| OH_NATIVEXCOMPONENT_RIGHT_BUTTON = 0x02 | Right mouse button. |
| OH_NATIVEXCOMPONENT_MIDDLE_BUTTON = 0x04 | Middle mouse button. |
| OH_NATIVEXCOMPONENT_BACK_BUTTON = 0x08 | Back button on the left of the mouse. |
| OH_NATIVEXCOMPONENT_FORWARD_BUTTON = 0x10 | Forward key on the left of the mouse. |
OH_NativeXComponent_TouchEvent_SourceTool
enum OH_NativeXComponent_TouchEvent_SourceTool
Description
Enumerates the source tool types of touch events.
Since: 10
| Value | Description |
|---|---|
| OH_NATIVEXCOMPONENT_SOURCETOOL_UNKNOWN = 0 | Unknown source tool. |
| OH_NATIVEXCOMPONENT_SOURCETOOL_FINGER = 1 | Finger. |
| OH_NATIVEXCOMPONENT_SOURCETOOL_PEN = 2 | Pen. |
| OH_NATIVEXCOMPONENT_SOURCETOOL_RUBBER = 3 | Eraser. |
| OH_NATIVEXCOMPONENT_SOURCETOOL_BRUSH = 4 | Brush. |
| OH_NATIVEXCOMPONENT_SOURCETOOL_PENCIL = 5 | Pencil. |
| OH_NATIVEXCOMPONENT_SOURCETOOL_AIRBRUSH = 6 | Airbrush. |
| OH_NATIVEXCOMPONENT_SOURCETOOL_MOUSE = 7 | Mouse pointer. |
| OH_NATIVEXCOMPONENT_SOURCETOOL_LENS = 8 | Lens. |
| OH_NATIVEXCOMPONENT_SOURCETOOL_TOUCHPAD = 9 | Touchpad. |
Function Description
OH_NativeXComponent_GetXComponentId()
int32_t OH_NativeXComponent_GetXComponentId(OH_NativeXComponent* component, char* id, uint64_t* size)
Description
Obtains the ID of ArkUI XComponent.
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| char* id | Pointer to the character buffer for storing the ID of the OH_NativeXComponent instance. Note that null terminators will be attached to the character buffer, so the size of the character buffer should be at least one unit greater than the length of the real ID. The recommended size is [OH_XCOMPONENT_ID_LEN_MAX + 1]. |
| uint64_t* size | Pointer to the length of the ID, used to receive the length information of the ID. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_GetXComponentSize()
int32_t OH_NativeXComponent_GetXComponentSize(OH_NativeXComponent* component, const void* window, uint64_t* width, uint64_t* height)
Description
Obtains the size of the surface held by the ArkUI XComponent.
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| const void* window | Handle to the NativeWindow instance. |
| uint64_t* width | Pointer to the width of the current surface. Unit: vp. |
| uint64_t* height | Pointer to the height of the current surface. Unit: vp. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_GetXComponentOffset()
int32_t OH_NativeXComponent_GetXComponentOffset(OH_NativeXComponent* component, const void* window, double* x, double* y)
Description
Obtains the offset of the surface held by the XComponent relative to the upper left corner of its parent component.
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| const void* window | Handle to the NativeWindow instance. |
| double* x | Pointer to the x-coordinate of the current surface relative to the upper left corner of the XComponent's parent component. Unit: vp. |
| double* y | Pointer to the y-coordinate of the current surface relative to the upper left corner of the XComponent's parent component. Unit: vp. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_GetTouchEvent()
int32_t OH_NativeXComponent_GetTouchEvent(OH_NativeXComponent* component, const void* window, OH_NativeXComponent_TouchEvent* touchEvent)
Description
Obtains the touch event scheduled by the ArkUI XComponent.
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| const void* window | Handle to the NativeWindow instance. |
| OH_NativeXComponent_TouchEvent* touchEvent | Pointer to the current touch event. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_GetTouchPointToolType()
int32_t OH_NativeXComponent_GetTouchPointToolType(OH_NativeXComponent* component, uint32_t pointIndex,OH_NativeXComponent_TouchPointToolType* toolType)
Description
Obtains the ArkUI XComponent touch point tool type.
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| uint32_t pointIndex | Pointer to the index of the touch point. |
| OH_NativeXComponent_TouchPointToolType* toolType | Pointer to the tool type. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_GetTouchPointTiltX()
int32_t OH_NativeXComponent_GetTouchPointTiltX(OH_NativeXComponent* component, uint32_t pointIndex, float* tiltX)
Description
Obtains the angle between the Y-Z plane of the ArkUI XComponent touch point and the x-axis.
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| uint32_t pointIndex | Pointer to the index of the touch point. |
| float* tiltX | Pointer to the angle between the Y-Z plane of the touch point and the x-axis. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_GetTouchPointTiltY()
int32_t OH_NativeXComponent_GetTouchPointTiltY(OH_NativeXComponent* component, uint32_t pointIndex, float* tiltY)
Description
Obtains the angle between the X-Z plane of the ArkUI XComponent touch point and the y-axis.
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| uint32_t pointIndex | Pointer to the index of the touch point. |
| float* tiltY | Pointer to the angle between the X-Z plane of the touch point and the y-axis. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_GetTouchPointWindowX()
int32_t OH_NativeXComponent_GetTouchPointWindowX(OH_NativeXComponent* component, uint32_t pointIndex, float* windowX)
Description
Obtains the x-coordinate of the touch point relative to the upper left corner of the application window where the ArkUI XComponent is located.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| uint32_t pointIndex | Pointer to the index of the touch point. |
| float* windowX | Pointer to the x-coordinate of the touch point relative to the upper left corner of the application window. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if the component, windowX, or native XComponent is a null pointer. |
OH_NativeXComponent_GetTouchPointWindowY()
int32_t OH_NativeXComponent_GetTouchPointWindowY(OH_NativeXComponent* component, uint32_t pointIndex, float* windowY)
Description
Obtains the y-coordinate of the touch point relative to the upper left corner of the application window where the ArkUI XComponent is located.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| uint32_t pointIndex | Pointer to the index of the touch point. |
| float* windowY | Pointer to the y-coordinate of the touch point relative to the upper left corner of the application window. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if the component, windowY, or native XComponent is a null pointer. |
OH_NativeXComponent_GetTouchPointDisplayX()
int32_t OH_NativeXComponent_GetTouchPointDisplayX(OH_NativeXComponent* component, uint32_t pointIndex, float* displayX)
Description
Obtains the x-coordinate of the touch point relative to the upper left corner of the screen where the ArkUI XComponent is located.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| uint32_t pointIndex | Pointer to the index of the touch point. |
| float* displayX | Pointer to the x-coordinate of the touch point relative to the upper left corner of the screen. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if the component, displayX, or native XComponent is a null pointer. |
OH_NativeXComponent_GetTouchPointDisplayY()
int32_t OH_NativeXComponent_GetTouchPointDisplayY(OH_NativeXComponent* component, uint32_t pointIndex, float* displayY)
Description
Obtains the y-coordinate of the touch point relative to the upper left corner of the screen where the ArkUI XComponent is located.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| uint32_t pointIndex | Pointer to the index of the touch point. |
| float* displayY | Pointer to the y-coordinate of the touch point relative to the upper left corner of the screen. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if the component, displayY, or native XComponent is a null pointer. |
OH_NativeXComponent_GetHistoricalPoints()
int32_t OH_NativeXComponent_GetHistoricalPoints(OH_NativeXComponent* component, const void* window,int32_t* size, OH_NativeXComponent_HistoricalPoint** historicalPoints)
Description
Obtains the historical touch point data for the touch event of an OH_NativeXComponent instance. Some input devices report touch points at very high frequencies (up to 1 ms intervals). However, since UI updates typically do not require such high-frequency updates, the system consolidates touch events and reports them once per frame. All touch points collected during the current frame are preserved as historical touch points for applications that need direct access to this raw data.
Since: 10
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| const void* window | Handle to the NativeWindow instance. |
| int32_t* size | Length of the historical touch point array. |
| OH_NativeXComponent_HistoricalPoint** historicalPoints | Pointer to the historical touch point array. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_GetMouseEvent()
int32_t OH_NativeXComponent_GetMouseEvent(OH_NativeXComponent* component, const void* window, OH_NativeXComponent_MouseEvent* mouseEvent)
Description
Obtains the mouse event scheduled by the ArkUI XComponent.
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| const void* window | Handle to the NativeWindow instance. |
| OH_NativeXComponent_MouseEvent* mouseEvent | Pointer to the current mouse event. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_RegisterCallback()
int32_t OH_NativeXComponent_RegisterCallback(OH_NativeXComponent* component, OH_NativeXComponent_Callback* callback)
Description
Registers a callback for this OH_NativeXComponent instance.
Since: 8
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| OH_NativeXComponent_Callback* callback | Pointer to the surface lifecycle and touch event callback. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_RegisterMouseEventCallback()
int32_t OH_NativeXComponent_RegisterMouseEventCallback(OH_NativeXComponent* component, OH_NativeXComponent_MouseEvent_Callback* callback)
Description
Registers a mouse event callback for this OH_NativeXComponent instance.
Since: 9
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| OH_NativeXComponent_MouseEvent_Callback* callback | Pointer to the mouse event callback. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_GetExtraMouseEventInfo()
int32_t OH_NativeXComponent_GetExtraMouseEventInfo(OH_NativeXComponent* component, OH_NativeXComponent_ExtraMouseEventInfo** extraMouseEventInfo)
Description
Obtains extended mouse event information from this OH_NativeXComponent instance.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| OH_NativeXComponent_ExtraMouseEventInfo** extraMouseEventInfo | Address of a pointer to the OH_NativeXComponent_ExtraMouseEventInfo type. |
Returns
| 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_NativeXComponent_GetMouseEventModifierKeyStates()
int32_t OH_NativeXComponent_GetMouseEventModifierKeyStates(OH_NativeXComponent_ExtraMouseEventInfo* extraMouseEventInfo, uint64_t* keys)
Description
Obtains the state of modifier keys from an OH_NativeXComponent_ExtraMouseEventInfo instance.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent_ExtraMouseEventInfo* extraMouseEventInfo | Pointer to the extended mouse event information instance. |
| uint64_t* keys | Address of a 64-bit unsigned integer to receive the modifier key press state information. |
Returns
| 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_NativeXComponent_RegisterFocusEventCallback()
int32_t OH_NativeXComponent_RegisterFocusEventCallback(OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window))
Description
Registers a focus event callback for this OH_NativeXComponent instance.
Since: 10
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| void (*callback)(OH_NativeXComponent* component, void* window) | Pointer to the focus event callback. - window: handle to the NativeWindow instance. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_RegisterKeyEventCallback()
int32_t OH_NativeXComponent_RegisterKeyEventCallback(OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window))
Description
Registers a key event callback for this OH_NativeXComponent instance.
Since: 10
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| void (*callback)(OH_NativeXComponent* component, void* window) | Pointer to the key event callback. - window: handle to the NativeWindow instance. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_RegisterBlurEventCallback()
int32_t OH_NativeXComponent_RegisterBlurEventCallback(OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window))
Description
Registers a blur event callback for this OH_NativeXComponent instance.
Since: 10
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| void (*callback)(OH_NativeXComponent* component, void* window) | Pointer to the blur event callback. - window: handle to the NativeWindow instance. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_GetKeyEvent()
int32_t OH_NativeXComponent_GetKeyEvent(OH_NativeXComponent* component, OH_NativeXComponent_KeyEvent** keyEvent)
Description
Obtains the key event scheduled by the ArkUI XComponent.
Since: 10
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| OH_NativeXComponent_KeyEvent** keyEvent | Pointer to the current key event. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_GetKeyEventAction()
int32_t OH_NativeXComponent_GetKeyEventAction(OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_KeyAction* action)
Description
Obtains the action of the specified key event.
Since: 10
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent_KeyEvent* keyEvent | Pointer to an OH_NativeXComponent_KeyEvent instance. |
| OH_NativeXComponent_KeyAction* action | Pointer to the key event action. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_GetKeyEventCode()
int32_t OH_NativeXComponent_GetKeyEventCode(OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_KeyCode* code)
Description
Obtains the key code of the specified key event.
Since: 10
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent_KeyEvent* keyEvent | Pointer to an OH_NativeXComponent_KeyEvent instance. |
| OH_NativeXComponent_KeyCode* code | Pointer to the key code of the key event. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_GetKeyEventSourceType()
int32_t OH_NativeXComponent_GetKeyEventSourceType(OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_EventSourceType* sourceType)
Description
Obtains the source type of the specified key event.
Since: 10
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent_KeyEvent* keyEvent | Pointer to an OH_NativeXComponent_KeyEvent instance. |
| OH_NativeXComponent_EventSourceType* sourceType | Pointer to the source type of the key event. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_GetKeyEventDeviceId()
int32_t OH_NativeXComponent_GetKeyEventDeviceId(OH_NativeXComponent_KeyEvent* keyEvent, int64_t* deviceId)
Description
Obtains the device ID of the specified key event.
Since: 10
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent_KeyEvent* keyEvent | Pointer to an OH_NativeXComponent_KeyEvent instance. |
| int64_t* deviceId | Pointer to the device ID of the key event. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_GetKeyEventTimestamp()
int32_t OH_NativeXComponent_GetKeyEventTimestamp(OH_NativeXComponent_KeyEvent* keyEvent, int64_t* timestamp)
Description
Obtains the timestamp of the specified key event.
Since: 10
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent_KeyEvent* keyEvent | Pointer to an OH_NativeXComponent_KeyEvent instance. |
| int64_t* timestamp | Pointer to the timestamp of the key event. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_GetKeyEventModifierKeyStates()
int32_t OH_NativeXComponent_GetKeyEventModifierKeyStates(OH_NativeXComponent_KeyEvent* keyEvent, uint64_t* keys)
Description
Obtains the state of modifier keys from a key event.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent_KeyEvent* keyEvent | Pointer to the key event. |
| uint64_t* keys | Address of a 64-bit unsigned integer to receive the modifier key press state information. |
Returns
| 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_NativeXComponent_GetKeyEventNumLockState()
int32_t OH_NativeXComponent_GetKeyEventNumLockState(OH_NativeXComponent_KeyEvent* keyEvent, bool* isNumLockOn)
Description
Obtains the state of the NumLock key from a key event.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent_KeyEvent* keyEvent | Pointer to the key event. |
| bool* isNumLockOn | Pointer to a boolean variable to receive the state of the NumLock key. true: NumLock is enabled. false: NumLock is disabled. |
Returns
| 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_NativeXComponent_GetKeyEventCapsLockState()
int32_t OH_NativeXComponent_GetKeyEventCapsLockState(OH_NativeXComponent_KeyEvent* keyEvent, bool* isCapsLockOn)
Description
Obtains the state of the CapsLock key from a key event.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent_KeyEvent* keyEvent | Pointer to the key event. |
| bool* isCapsLockOn | Pointer to a boolean variable to receive the state of the CapsLock key. true: CapsLock is enabled. false: CapsLock is disabled. |
Returns
| 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_NativeXComponent_GetKeyEventScrollLockState()
int32_t OH_NativeXComponent_GetKeyEventScrollLockState(OH_NativeXComponent_KeyEvent* keyEvent, bool* isScrollLockOn)
Description
Obtains the state of the ScrollLock key from a key event.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent_KeyEvent* keyEvent | Pointer to the key event. |
| bool* isScrollLockOn | Pointer to a boolean variable to receive the state of the ScrollLock key. true: ScrollLock is enabled. false: ScrollLock is disabled. |
Returns
| 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_NativeXComponent_SetExpectedFrameRateRange()
int32_t OH_NativeXComponent_SetExpectedFrameRateRange(OH_NativeXComponent* component, OH_NativeXComponent_ExpectedRateRange* range)
Description
Sets the expected frame rate range.
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| OH_NativeXComponent_ExpectedRateRange* range | Pointer to the expected frame rate information object of the OH_NativeXComponent_ExpectedRateRange type. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_RegisterOnFrameCallback()
int32_t OH_NativeXComponent_RegisterOnFrameCallback(OH_NativeXComponent* component,void (*callback)(OH_NativeXComponent* component, uint64_t timestamp, uint64_t targetTimestamp))
Description
Registers the display update callback for this OH_NativeXComponent instance and enables the callback for each frame.
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| void (*callback)(OH_NativeXComponent* component, uint64_t timestamp, uint64_t targetTimestamp) | Pointer to the display update callback. - timestamp: time when the current frame arrives, in nanoseconds. - targetTimestamp: expected arrival time of the next frame, in nanoseconds. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_UnregisterOnFrameCallback()
int32_t OH_NativeXComponent_UnregisterOnFrameCallback(OH_NativeXComponent* component)
Description
Deregisters the display update callback for this OH_NativeXComponent instance and disables the callback for each frame.
Since: 11
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_AttachNativeRootNode()
int32_t OH_NativeXComponent_AttachNativeRootNode(OH_NativeXComponent* component, ArkUI_NodeHandle root)
Description
Attaches the UI component created through the native API of ArkUI to this OH_NativeXComponent instance.
Since: 12
Deprecated from: 20
Substitute: OH_ArkUI_NodeContent_AddNode
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| ArkUI_NodeHandle root | Pointer to the component instance created through the native API. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_DetachNativeRootNode()
int32_t OH_NativeXComponent_DetachNativeRootNode(OH_NativeXComponent* component, ArkUI_NodeHandle root)
Description
Detaches the native component of ArkUI from this OH_NativeXComponent instance.
Since: 12
Deprecated from: 20
Substitute: OH_ArkUI_NodeContent_RemoveNode
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| ArkUI_NodeHandle root | Pointer to the component instance created through the native API. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_RegisterUIInputEventCallback()
int32_t OH_NativeXComponent_RegisterUIInputEventCallback(OH_NativeXComponent *component,void (*callback)(OH_NativeXComponent *component, ArkUI_UIInputEvent *event,ArkUI_UIInputEvent_Type type),ArkUI_UIInputEvent_Type type)
Description
Registers a UI input event callback for this OH_NativeXComponent instance and enables this callback to be invoked when a UI input event is received. Currently, only axis events are supported.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent *component | Pointer to an OH_NativeXComponent instance. |
| void (*callback)(OH_NativeXComponent *component, ArkUI_UIInputEvent *event,ArkUI_UIInputEvent_Type type) | Pointer to the UI input event callback. - event: pointer to the UI input event. |
| ArkUI_UIInputEvent_Type type | Type of the current UI input event. |
Returns
| 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_NativeXComponent_RegisterOnTouchInterceptCallback()
int32_t OH_NativeXComponent_RegisterOnTouchInterceptCallback(OH_NativeXComponent* component, HitTestMode (*callback)(OH_NativeXComponent* component, ArkUI_UIInputEvent* event))
Description
Registers a custom event intercept callback for this OH_NativeXComponent instance and enables this callback to be invoked during hit testing. UI input–related operations are not supported on event objects received through this callback. For full functionality, use the NODE_ON_TOUCH_INTERCEPT event on native nodes instead.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| HitTestMode (*callback)(OH_NativeXComponent* component, ArkUI_UIInputEvent* event) | Pointer to the custom event intercept callback. - event: pointer to the UI input event. |
Returns
| 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_NativeXComponent_SetNeedSoftKeyboard()
int32_t OH_NativeXComponent_SetNeedSoftKeyboard(OH_NativeXComponent* component, bool needSoftKeyboard)
Description
Sets whether the soft keyboard is required for this OH_NativeXComponent instance.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| bool needSoftKeyboard | Whether the soft keyboard is required for the current OH_NativeXComponent instance. true if the soft keyboard is required, false otherwise. The default value is false. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_RegisterSurfaceShowCallback()
int32_t OH_NativeXComponent_RegisterSurfaceShowCallback(OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window))
Description
Registers a surface display callback for this OH_NativeXComponent instance. This callback is invoked after the application is switched to the foreground.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| void (*callback)(OH_NativeXComponent* component, void* window) | Pointer to the surface display callback. - window: handle to the NativeWindow instance. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_RegisterSurfaceHideCallback()
int32_t OH_NativeXComponent_RegisterSurfaceHideCallback(OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window))
Description
Registers a surface hiding callback for this OH_NativeXComponent instance. This callback is invoked after the application is switched to the background.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| void (*callback)(OH_NativeXComponent* component, void* window) | Pointer to the surface hiding callback. - window: handle to the NativeWindow instance. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_NativeXComponent_GetTouchEventSourceType()
int32_t OH_NativeXComponent_GetTouchEventSourceType(OH_NativeXComponent* component, int32_t pointId, OH_NativeXComponent_EventSourceType* sourceType)
Description
Obtains the touch event source type of an ArkUI XComponent instance.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| int32_t pointId | ID of the touch point. The touch event source type can be correctly returned only when the ID passed in is the ID of the touch point that triggers the touch event. Otherwise, OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER is returned. |
| OH_NativeXComponent_EventSourceType* sourceType | Pointer to the touch event source type. |
Returns
| Type | Description |
|---|---|
| int32_t | Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. Returns OH_NATIVEXCOMPONENT_RESULT_FAILED if any other error occurs. |
OH_NativeXComponent_GetNativeXComponent()
OH_NativeXComponent* OH_NativeXComponent_GetNativeXComponent(ArkUI_NodeHandle node)
Description
Obtains a pointer of the OH_NativeXComponent type based on the specified component instance created by the native API.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Pointer to the component instance created through the native API. |
Returns
| Type | Description |
|---|---|
| OH_NativeXComponent* | Pointer to an OH_NativeXComponent instance. |
OH_NativeXComponent_GetNativeAccessibilityProvider()
int32_t OH_NativeXComponent_GetNativeAccessibilityProvider(OH_NativeXComponent* component, ArkUI_AccessibilityProvider** handle)
Description
Obtains the accessibility provider handle for an ArkUI XComponent.
Since: 13
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| ArkUI_AccessibilityProvider** handle | Pointer to an ArkUI_AccessibilityProvider instance. |
Returns
| Type | Description |
|---|---|
| int32_t | Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. Returns OH_NATIVEXCOMPONENT_RESULT_FAILED if any other error occurs. |
OH_NativeXComponent_RegisterKeyEventCallbackWithResult()
int32_t OH_NativeXComponent_RegisterKeyEventCallbackWithResult(OH_NativeXComponent* component, bool (*callback)(OH_NativeXComponent* component, void* window))
Description
Registers a key event callback with a return value for this OH_NativeXComponent instance. The callback must return a result (true or false). If the callback returns true, the event will not be further propagated. If it returns false, the event will continue to be processed according to the normal event handling flow.
Since: 14
Parameters
| Name | Description |
|---|---|
| OH_NativeXComponent* component | Pointer to an OH_NativeXComponent instance. |
| bool (*callback)(OH_NativeXComponent* component, void* window) | Pointer to the key event callback. - window: handle to the NativeWindow instance. If the callback returns true, the event will not be further propagated. If it returns false, the event will continue to be processed according to the normal event handling flow. |
Returns
| Type | Description |
|---|---|
| int32_t | Result code. Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if the operation is successful. Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter error occurs. |
OH_ArkUI_XComponent_StartImageAnalyzer()
int32_t OH_ArkUI_XComponent_StartImageAnalyzer(ArkUI_NodeHandle node, void* userData,void (*callback)(ArkUI_NodeHandle node, ArkUI_XComponent_ImageAnalyzerState statusCode, void* userData))
Description
Starts AI image analysis for this XComponent instance. Before calling this API, make sure the AI image analyzer is enabled.
Since: 18
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | XComponent instance. |
| void* userData | Pointer to the data that you need to obtain when the callback function is executed. |
| void (*callback)(ArkUI_NodeHandle node, ArkUI_XComponent_ImageAnalyzerState statusCode, void* userData) | Callback function triggered when the AI image analysis status is updated. - statusCode: one of the input parameters of the callback function, indicating the current image analysis status. |
Returns
| 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_XComponent_StopImageAnalyzer()
int32_t OH_ArkUI_XComponent_StopImageAnalyzer(ArkUI_NodeHandle node)
Description
Stops AI image analysis for this XComponent instance.
Since: 18
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | XComponent instance. |
Returns
| 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_SurfaceHolder_Create()
OH_ArkUI_SurfaceHolder* OH_ArkUI_SurfaceHolder_Create(ArkUI_NodeHandle node)
Description
Creates an OH_ArkUI_SurfaceHolder object for an XComponent.
Since: 19
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Pointer to the XComponent instance created through the native API. |
Returns
| Type | Description |
|---|---|
| OH_ArkUI_SurfaceHolder* | Pointer to the created OH_ArkUI_SurfaceHolder object. |
OH_ArkUI_SurfaceHolder_Dispose()
void OH_ArkUI_SurfaceHolder_Dispose(OH_ArkUI_SurfaceHolder* surfaceHolder)
Description
Disposes of an OH_ArkUI_SurfaceHolder object.
Since: 19
Parameters
| Name | Description |
|---|---|
| OH_ArkUI_SurfaceHolder* surfaceHolder | Pointer to the target OH_ArkUI_SurfaceHolder instance. |
OH_ArkUI_SurfaceHolder_SetUserData()
int32_t OH_ArkUI_SurfaceHolder_SetUserData(OH_ArkUI_SurfaceHolder* surfaceHolder, void* userData)
Description
Stores custom data in an OH_ArkUI_SurfaceHolder instance.
Since: 19
Parameters
| Name | Description |
|---|---|
| OH_ArkUI_SurfaceHolder* surfaceHolder | Pointer to the target OH_ArkUI_SurfaceHolder instance. |
| void* userData | Pointer to the custom data to be stored. |
Returns
| 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_SurfaceHolder_GetUserData()
void* OH_ArkUI_SurfaceHolder_GetUserData(OH_ArkUI_SurfaceHolder* surfaceHolder)
Description
Obtains the custom data stored in an OH_ArkUI_SurfaceHolder instance.
Since: 19
Parameters
| Name | Description |
|---|---|
| OH_ArkUI_SurfaceHolder* surfaceHolder | Pointer to the target OH_ArkUI_SurfaceHolder instance. |
Returns
| Type | Description |
|---|---|
| void* | Custom data. |
OH_ArkUI_SurfaceCallback_Create()
OH_ArkUI_SurfaceCallback* OH_ArkUI_SurfaceCallback_Create()
Description
Creates an OH_ArkUI_SurfaceCallback object.
Since: 19
Returns
| Type | Description |
|---|---|
| OH_ArkUI_SurfaceCallback* | Pointer to the created OH_ArkUI_SurfaceCallback object. |
OH_ArkUI_SurfaceCallback_Dispose()
void OH_ArkUI_SurfaceCallback_Dispose(OH_ArkUI_SurfaceCallback* callback)
Description
Disposes of an OH_ArkUI_SurfaceCallback object.
Since: 19
Parameters
| Name | Description |
|---|---|
| OH_ArkUI_SurfaceCallback* callback | Pointer to the target OH_ArkUI_SurfaceCallback instance. |
OH_ArkUI_SurfaceCallback_SetSurfaceCreatedEvent()
void OH_ArkUI_SurfaceCallback_SetSurfaceCreatedEvent(OH_ArkUI_SurfaceCallback* callback,void (*onSurfaceCreated)(OH_ArkUI_SurfaceHolder* surfaceHolder))
Description
Sets the creation callback event in the surface lifecycle callbacks.
Since: 19
Parameters
| Name | Description |
|---|---|
| OH_ArkUI_SurfaceCallback* callback | Pointer to the surface lifecycle callback. |
| void (*onSurfaceCreated)(OH_ArkUI_SurfaceHolder* surfaceHolder) | Callback event triggered when the surface is created. - surfaceHolder: pointer to the target OH_ArkUI_SurfaceHolder instance. |
OH_ArkUI_SurfaceCallback_SetSurfaceChangedEvent()
void OH_ArkUI_SurfaceCallback_SetSurfaceChangedEvent(OH_ArkUI_SurfaceCallback* callback,void (*onSurfaceChanged)(OH_ArkUI_SurfaceHolder* surfaceHolder, uint64_t width, uint64_t height))
Description
Sets the size change callback event in the surface lifecycle callbacks.
Since: 19
Parameters
| Name | Description |
|---|---|
| OH_ArkUI_SurfaceCallback* callback | Pointer to the surface lifecycle callback. |
| void (*onSurfaceChanged)(OH_ArkUI_SurfaceHolder* surfaceHolder, uint64_t width, uint64_t height) | Callback event triggered when the surface size changes. - surfaceHolder: pointer to the target OH_ArkUI_SurfaceHolder instance. - width: new width of the surface after the size change. Unit: vp. - height: new height of the surface after the size change. Unit: vp. |
OH_ArkUI_SurfaceCallback_SetSurfaceDestroyedEvent()
void OH_ArkUI_SurfaceCallback_SetSurfaceDestroyedEvent(OH_ArkUI_SurfaceCallback* callback,void (*onSurfaceDestroyed)(OH_ArkUI_SurfaceHolder* surfaceHolder))
Description
Sets the destruction callback event in the surface lifecycle callbacks.
Since: 19
Parameters
| Name | Description |
|---|---|
| OH_ArkUI_SurfaceCallback* callback | Pointer to the surface lifecycle callback. |
| void (*onSurfaceDestroyed)(OH_ArkUI_SurfaceHolder* surfaceHolder) | Callback event triggered when the surface is destroyed. - surfaceHolder: pointer to the target OH_ArkUI_SurfaceHolder instance. |
OH_ArkUI_SurfaceHolder_AddSurfaceCallback()
int32_t OH_ArkUI_SurfaceHolder_AddSurfaceCallback(OH_ArkUI_SurfaceHolder* surfaceHolder,OH_ArkUI_SurfaceCallback* callback)
Description
Adds a surface lifecycle callback to an OH_ArkUI_SurfaceHolder instance.
Since: 19
Parameters
| Name | Description |
|---|---|
| OH_ArkUI_SurfaceHolder* surfaceHolder | Pointer to the target OH_ArkUI_SurfaceHolder instance. |
| OH_ArkUI_SurfaceCallback* callback | Pointer to the new callback. |
Returns
| 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_SurfaceHolder_RemoveSurfaceCallback()
int32_t OH_ArkUI_SurfaceHolder_RemoveSurfaceCallback(OH_ArkUI_SurfaceHolder* surfaceHolder,OH_ArkUI_SurfaceCallback* callback)
Description
Removes a previously added surface lifecycle callback from an OH_ArkUI_SurfaceHolder instance.
Since: 19
Parameters
| Name | Description |
|---|---|
| OH_ArkUI_SurfaceHolder* surfaceHolder | Pointer to the target OH_ArkUI_SurfaceHolder instance. |
| OH_ArkUI_SurfaceCallback* callback | Pointer to the callback to be removed. |
Returns
| 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_XComponent_GetNativeWindow()
OHNativeWindow* OH_ArkUI_XComponent_GetNativeWindow(OH_ArkUI_SurfaceHolder* surfaceHolder)
Description
Obtains the NativeWindow instance associated with an OH_ArkUI_SurfaceHolder instance.
Since: 19
Parameters
| Name | Description |
|---|---|
| OH_ArkUI_SurfaceHolder* surfaceHolder | Pointer to the target OH_ArkUI_SurfaceHolder instance. |
Returns
| Type | Description |
|---|---|
| NativeWindow* | NativeWindow instance associated with the OH_ArkUI_SurfaceHolder instance. |
OH_ArkUI_XComponent_SetAutoInitialize()
int32_t OH_ArkUI_XComponent_SetAutoInitialize(ArkUI_NodeHandle node, bool autoInitialize)
Description
Sets whether the XComponent component needs to automatically initialize the surface.
Since: 19
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Pointer to the XComponent component instance. |
| bool autoInitialize | Whether the XComponent component needs to automatically initialize the surface. If autoInitialize is true, the OnSurfaceCreated callback will be triggered when the component is attached to the tree, and the OnSurfaceDestroyed callback will be triggered when the component is detached from the tree. If the value is false, the component does not need to automatically initialize the surface. The default value of autoInitialize is true. |
Returns
| 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_XComponent_Initialize()
int32_t OH_ArkUI_XComponent_Initialize(ArkUI_NodeHandle node)
Description
Initializes the surface held by the XComponent component.
Since: 19
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Pointer to the XComponent component instance. |
Returns
| 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. Returns ARKUI_ERROR_CODE_XCOMPONENT_STATE_INVALID if the surface held by the XComponent component has been initialized. |
OH_ArkUI_XComponent_Finalize()
int32_t OH_ArkUI_XComponent_Finalize(ArkUI_NodeHandle node)
Description
Destroys the surface held by the XComponent component.
Since: 19
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Pointer to the XComponent component instance. |
Returns
| 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. Returns ARKUI_ERROR_CODE_XCOMPONENT_STATE_INVALID if the surface held by the XComponent component has been destroyed. |
OH_ArkUI_XComponent_IsInitialized()
int32_t OH_ArkUI_XComponent_IsInitialized(ArkUI_NodeHandle node, bool* isInitialized)
Description
Checks whether the surface held by the XComponent component is initialized.
Since: 19
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | Pointer to the XComponent component instance. |
| bool* isInitialized | Whether the surface held by the XComponent component is initialized. true: The surface is initialized. false: The surface is not initialized. |
Returns
| 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_XComponent_SetExpectedFrameRateRange()
int32_t OH_ArkUI_XComponent_SetExpectedFrameRateRange(ArkUI_NodeHandle node, OH_NativeXComponent_ExpectedRateRange range)
Description
Sets the expected frame rate range for the XComponent.
Since: 20
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | XComponent instance. |
| OH_NativeXComponent_ExpectedRateRange range | Expected frame rate information object of the OH_NativeXComponent_ExpectedRateRange type. |
Returns
| 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_XComponent_RegisterOnFrameCallback()
int32_t OH_ArkUI_XComponent_RegisterOnFrameCallback(ArkUI_NodeHandle node,void (*callback)(ArkUI_NodeHandle node, uint64_t timestamp, uint64_t targetTimestamp))
Description
Registers a frame callback function for the XComponent.
Since: 20
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | XComponent instance. |
| void (*callback)(ArkUI_NodeHandle node, uint64_t timestamp, uint64_t targetTimestamp) | Pointer to the frame callback function. - timestamp: time when the current frame arrives, in nanoseconds. - targetTimestamp: expected arrival time of the next frame, in nanoseconds. |
Returns
| 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_XComponent_UnregisterOnFrameCallback()
int32_t OH_ArkUI_XComponent_UnregisterOnFrameCallback(ArkUI_NodeHandle node)
Description
Unregisters the frame callback function for the XComponent.
Since: 20
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | XComponent instance. |
Returns
| 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_XComponent_SetNeedSoftKeyboard()
int32_t OH_ArkUI_XComponent_SetNeedSoftKeyboard(ArkUI_NodeHandle node, bool needSoftKeyboard)
Description
Sets whether the soft keyboard is required for the XComponent.
Since: 20
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | XComponent instance. |
| bool needSoftKeyboard | Whether the soft keyboard is required. true if the soft keyboard is required, false otherwise. The default value is false. |
Returns
| 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_AccessibilityProvider_Create()
ArkUI_AccessibilityProvider* OH_ArkUI_AccessibilityProvider_Create(ArkUI_NodeHandle node)
Description
Creates an ArkUI_AccessibilityProvider instance for this XComponent instance.
Since: 20
Parameters
| Name | Description |
|---|---|
| ArkUI_NodeHandle node | XComponent instance. |
Returns
| Type | Description |
|---|---|
| ArkUI_AccessibilityProvider* | Pointer of the ArkUI_AccessibilityProvider type. |
OH_ArkUI_AccessibilityProvider_Dispose()
void OH_ArkUI_AccessibilityProvider_Dispose(ArkUI_AccessibilityProvider* provider)
Description
Disposes of the ArkUI_AccessibilityProvider instance created using OH_ArkUI_AccessibilityProvider_Create.
Since: 20
Parameters
| Name | Description |
|---|---|
| ArkUI_AccessibilityProvider* provider | ArkUI_AccessibilityProvider instance created using OH_ArkUI_AccessibilityProvider_Create. |
OH_ArkUI_SurfaceCallback_SetSurfaceShowEvent()
void OH_ArkUI_SurfaceCallback_SetSurfaceShowEvent(OH_ArkUI_SurfaceCallback* callback,void (*onSurfaceShow)(OH_ArkUI_SurfaceHolder* surfaceHolder))
Description
Sets a surface display callback for this OH_ArkUI_SurfaceCallback instance. This callback is invoked when the application window has moved from the background to the foreground.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_ArkUI_SurfaceCallback* callback | Pointer to the target OH_ArkUI_SurfaceCallback instance. |
| onSurfaceShow | Pointer to the surface display callback. - surfaceHolder: pointer to the target OH_ArkUI_SurfaceHolder instance. |
OH_ArkUI_SurfaceCallback_SetSurfaceHideEvent()
void OH_ArkUI_SurfaceCallback_SetSurfaceHideEvent(OH_ArkUI_SurfaceCallback* callback,void (*onSurfaceHide)(OH_ArkUI_SurfaceHolder* surfaceHolder))
Description
Sets a surface hiding callback for this OH_ArkUI_SurfaceCallback instance. This callback is invoked when the application window has moved from the foreground to the background.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_ArkUI_SurfaceCallback* callback | Pointer to the target OH_ArkUI_SurfaceCallback instance. |
| onSurfaceHide | Pointer to the surface hiding callback. - surfaceHolder: pointer to the target OH_ArkUI_SurfaceHolder instance. |
OH_ArkUI_XComponentSurfaceConfig_Create()
ArkUI_XComponentSurfaceConfig* OH_ArkUI_XComponentSurfaceConfig_Create()
Description
Creates an ArkUI_XComponentSurfaceConfig object for an XComponent.
Since: 22
Returns
| Type | Description |
|---|---|
| ArkUI_XComponentSurfaceConfig* | Pointer to the created ArkUI_XComponentSurfaceConfig object. |
OH_ArkUI_XComponentSurfaceConfig_Dispose()
void OH_ArkUI_XComponentSurfaceConfig_Dispose(ArkUI_XComponentSurfaceConfig* config)
Description
Disposes of an ArkUI_XComponentSurfaceConfig object.
Since: 22
Parameters
| Name | Description |
|---|---|
| ArkUI_XComponentSurfaceConfig* config | Pointer to the target ArkUI_XComponentSurfaceConfig object. |
OH_ArkUI_XComponentSurfaceConfig_SetIsOpaque()
void OH_ArkUI_XComponentSurfaceConfig_SetIsOpaque(ArkUI_XComponentSurfaceConfig* config, bool isOpaque)
Description
Sets whether the surface held by the XComponent should be treated as opaque during rendering, regardless of the actual pixel transparency.
Since: 22
Parameters
| Name | Description |
|---|---|
| ArkUI_XComponentSurfaceConfig* config | Pointer to the target ArkUI_XComponentSurfaceConfig instance. |
| bool isOpaque | Whether the surface held by the XComponent should be treated as opaque during rendering. true if the surface should be treated as opaque, false otherwise. The default value is false, which means pixel opacity of the surface content will be applied during rendering. |
OH_ArkUI_SurfaceHolder_SetSurfaceConfig()
int32_t OH_ArkUI_SurfaceHolder_SetSurfaceConfig(OH_ArkUI_SurfaceHolder* surfaceHolder, ArkUI_XComponentSurfaceConfig *config)
Description
Sets the surface configuration for the OH_ArkUI_SurfaceHolder instance.
Since: 22
Parameters
| Name | Description |
|---|---|
| OH_ArkUI_SurfaceHolder* surfaceHolder | Pointer to the target OH_ArkUI_SurfaceHolder instance. |
| ArkUI_XComponentSurfaceConfig *config | Pointer to the target ArkUI_XComponentSurfaceConfig instance. |
Returns
| 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. |