harmony 鸿蒙native_interface_xcomponent.h

  • 2025-06-12
  • 浏览 (5)

native_interface_xcomponent.h

概述

声明用于访问Native XComponent的API。

库: libace_ndk.z.so

引用文件:

起始版本: 8

相关模块:Native XComponent

汇总

结构体

名称 描述
struct  OH_NativeXComponent_TouchPoint 触摸事件中触摸点的信息。
struct  OH_NativeXComponent_TouchEvent 触摸事件。
struct  OH_NativeXComponent_MouseEvent 鼠标事件。
struct  OH_NativeXComponent_Callback 注册surface生命周期和触摸事件回调。
struct  OH_NativeXComponent_MouseEvent_Callback 注册鼠标事件回调。
struct  OH_NativeXComponent_ExpectedRateRange 定义期望帧率范围。

类型定义

名称 描述
typedef struct OH_NativeXComponentOH_NativeXComponent 提供封装的OH_NativeXComponent实例。
typedef struct OH_NativeXComponent_CallbackOH_NativeXComponent_Callback 注册surface生命周期和触摸事件回调。
typedef struct OH_NativeXComponent_MouseEvent_CallbackOH_NativeXComponent_MouseEvent_Callback 注册鼠标事件的回调。
typedef struct OH_NativeXComponent_KeyEventOH_NativeXComponent_KeyEvent 提供封装的OH_NativeXComponent_KeyEvent实例。
OH_NativeXComponent_ExtraMouseEventInfo 提供封装的扩展的鼠标事件信息实例。
OH_ArkUI_SurfaceCallback 定义surface生命周期回调函数。
OH_ArkUI_SurfaceHolder 提供封装的OH_ArkUI_SurfaceHolder实例。
OHNativeWindow 提供封装的NativeWindow实例。

枚举

名称 描述
{ OH_NATIVEXCOMPONENT_RESULT_SUCCESS = 0, OH_NATIVEXCOMPONENT_RESULT_FAILED = -1, OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER = -2 } 枚举API访问状态。
OH_NativeXComponent_TouchEventType {
OH_NATIVEXCOMPONENT_DOWN = 0, OH_NATIVEXCOMPONENT_UP, OH_NATIVEXCOMPONENT_MOVE, OH_NATIVEXCOMPONENT_CANCEL,
OH_NATIVEXCOMPONENT_UNKNOWN
}
触摸事件类型。
OH_NativeXComponent_TouchPointToolType {
OH_NATIVEXCOMPONENT_TOOL_TYPE_UNKNOWN = 0, OH_NATIVEXCOMPONENT_TOOL_TYPE_FINGER, OH_NATIVEXCOMPONENT_TOOL_TYPE_PEN, OH_NATIVEXCOMPONENT_TOOL_TYPE_RUBBER,
OH_NATIVEXCOMPONENT_TOOL_TYPE_BRUSH, OH_NATIVEXCOMPONENT_TOOL_TYPE_PENCIL, OH_NATIVEXCOMPONENT_TOOL_TYPE_AIRBRUSH, OH_NATIVEXCOMPONENT_TOOL_TYPE_MOUSE,
OH_NATIVEXCOMPONENT_TOOL_TYPE_LENS
}
触摸点工具类型。
OH_NativeXComponent_EventSourceType {
OH_NATIVEXCOMPONENT_SOURCE_TYPE_UNKNOWN = 0, OH_NATIVEXCOMPONENT_SOURCE_TYPE_MOUSE, OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHSCREEN, OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHPAD,
OH_NATIVEXCOMPONENT_SOURCE_TYPE_JOYSTICK, OH_NATIVEXCOMPONENT_SOURCE_TYPE_KEYBOARD
}
触摸事件源类型。
OH_NativeXComponent_MouseEventAction { OH_NATIVEXCOMPONENT_MOUSE_NONE = 0, OH_NATIVEXCOMPONENT_MOUSE_PRESS, OH_NATIVEXCOMPONENT_MOUSE_RELEASE, OH_NATIVEXCOMPONENT_MOUSE_MOVE } 鼠标事件动作。
OH_NativeXComponent_MouseEventButton {
OH_NATIVEXCOMPONENT_NONE_BUTTON = 0, OH_NATIVEXCOMPONENT_LEFT_BUTTON = 0x01, OH_NATIVEXCOMPONENT_RIGHT_BUTTON = 0x02, OH_NATIVEXCOMPONENT_MIDDLE_BUTTON = 0x04,
OH_NATIVEXCOMPONENT_BACK_BUTTON = 0x08, OH_NATIVEXCOMPONENT_FORWARD_BUTTON = 0x10
}
鼠标事件按键。
ArkUI_XComponent_ImageAnalyzerState { ARKUI_XCOMPONENT_AI_ANALYSIS_FINISHED = 0, ARKUI_XCOMPONENT_AI_ANALYSIS_DISABLED = 110000, ARKUI_XCOMPONENT_AI_ANALYSIS_UNSUPPORTED = 110001, ARKUI_XCOMPONENT_AI_ANALYSIS_ONGOING = 110002, ARKUI_XCOMPONENT_AI_ANALYSIS_STOPPED = 110003} XComponent图像AI分析状态码。

函数

名称 描述
int32_t OH_NativeXComponent_GetXComponentId (OH_NativeXComponent *component, char *id, uint64_t *size) 获取ArkUI XComponent的id。
int32_t OH_NativeXComponent_GetXComponentSize (OH_NativeXComponent *component, const void *window, uint64_t *width, uint64_t *height) 获取ArkUI XComponent持有的surface的大小。
int32_t OH_NativeXComponent_GetXComponentOffset (OH_NativeXComponent *component, const void *window, double *x, double *y) 获取ArkUI XComponent组件相对屏幕左上顶点的偏移量。
int32_t OH_NativeXComponent_GetTouchEvent (OH_NativeXComponent *component, const void *window, OH_NativeXComponent_TouchEvent *touchEvent) 获取ArkUI XComponent调度的触摸事件。
int32_t OH_NativeXComponent_GetTouchPointToolType (OH_NativeXComponent *component, uint32_t pointIndex, OH_NativeXComponent_TouchPointToolType *toolType) 获取ArkUI XComponent触摸点工具类型。
int32_t OH_NativeXComponent_GetTouchPointTiltX (OH_NativeXComponent *component, uint32_t pointIndex, float *tiltX) 获取ArkUI XComponent触摸点倾斜与X轴角度。
int32_t OH_NativeXComponent_GetTouchPointTiltY (OH_NativeXComponent *component, uint32_t pointIndex, float *tiltY) 获取ArkUI XComponent触摸点倾斜与Y轴角度。
int32_t OH_NativeXComponent_GetMouseEvent (OH_NativeXComponent *component, const void *window, OH_NativeXComponent_MouseEvent *mouseEvent) 获取ArkUI XComponent调度的鼠标事件。
int32_t OH_NativeXComponent_RegisterCallback (OH_NativeXComponent *component, OH_NativeXComponent_Callback *callback) 为此OH_NativeXComponent实例注册回调。
int32_t OH_NativeXComponent_RegisterMouseEventCallback (OH_NativeXComponent *component, OH_NativeXComponent_MouseEvent_Callback *callback) 为此OH_NativeXComponent实例注册鼠标事件回调。
int32_t OH_NativeXComponent_RegisterFocusEventCallback (OH_NativeXComponent *component, void(*callback)(OH_NativeXComponent *component, void *window)) 为此OH_NativeXComponent实例注册获焦事件回调。
int32_t OH_NativeXComponent_RegisterKeyEventCallback (OH_NativeXComponent *component, void(*callback)(OH_NativeXComponent *component, void *window)) 为此OH_NativeXComponent实例注册按键事件回调。
int32_t OH_NativeXComponent_RegisterKeyEventCallbackWithResult (OH_NativeXComponent *component, bool(*callback)(OH_NativeXComponent *component, void *window)) 为此OH_NativeXComponent实例注册有返回值的按键事件回调。
int32_t OH_NativeXComponent_RegisterBlurEventCallback (OH_NativeXComponent *component, void(*callback)(OH_NativeXComponent *component, void *window)) 为此OH_NativeXComponent实例注册失焦事件回调。
int32_t OH_NativeXComponent_GetKeyEvent (OH_NativeXComponent *component, OH_NativeXComponent_KeyEvent **keyEvent) 获取ArkUI XComponent调度的按键事件。
int32_t OH_NativeXComponent_GetKeyEventAction (OH_NativeXComponent_KeyEvent *keyEvent, OH_NativeXComponent_KeyAction *action) 获取传入按键事件的动作。
int32_t OH_NativeXComponent_GetKeyEventCode (OH_NativeXComponent_KeyEvent *keyEvent, OH_NativeXComponent_KeyCode *code) 获取传入按键事件的按键码。
int32_t OH_NativeXComponent_GetKeyEventSourceType (OH_NativeXComponent_KeyEvent *keyEvent, OH_NativeXComponent_EventSourceType *sourceType) 获取传入按键事件的事件源类型。
int32_t OH_NativeXComponent_GetKeyEventDeviceId (OH_NativeXComponent_KeyEvent *keyEvent, int64_t *deviceId) 获取传入按键事件的设备id。
int32_t OH_NativeXComponent_GetKeyEventTimeStamp (OH_NativeXComponent_KeyEvent *keyEvent, int64_t *timeStamp) 获取传入按键事件的时间戳。
int32_t OH_NativeXComponent_SetExpectedFrameRateRange (OH_NativeXComponent *component, OH_NativeXComponent_ExpectedRateRange *range) 设置期望帧率范围。
int32_t OH_NativeXComponent_RegisterOnFrameCallback (OH_NativeXComponent *component, void(*callback)(OH_NativeXComponent *component, uint64_t timestamp, uint64_t targetTimestamp)) 为此OH_NativeXComponent实例注册显示更新回调,并使能每帧回调此函数。
int32_t OH_NativeXComponent_UnregisterOnFrameCallback (OH_NativeXComponent *component) 为此OH_NativeXComponent实例取消注册回调函数,并关闭每帧回调此函数。
int32_t OH_NativeXComponent_AttachNativeRootNode (OH_NativeXComponent *component, ArkUI_NodeHandle root) 将通过ArkUI的native接口创建出来的UI组件挂载到当前XComponent上。
int32_t OH_NativeXComponent_DetachNativeRootNode (OH_NativeXComponent *component, ArkUI_NodeHandle root) 将ArkUI的native组件从当前XComponent上卸载.
int32_t OH_NativeXComponent_RegisterUIInputEventCallback (OH_NativeXComponent *component, void(*callback)(OH_NativeXComponent *component, ArkUI_UIInputEvent *event, ArkUI_UIInputEvent_Type type), ArkUI_UIInputEvent_Type type) 为此OH_NativeXComponent实例注册UI输入事件回调,并使能收到UI输入事件时回调此函数。
int32_t OH_NativeXComponent_RegisterOnTouchInterceptCallback (OH_NativeXComponent *component, HitTestMode(*callback)(OH_NativeXComponent *component, ArkUI_UIInputEvent *event)) 为此OH_NativeXComponent实例注册自定义事件拦截回调,并使能在做触摸测试时回调此函数。
int32_t OH_NativeXComponent_SetNeedSoftKeyboard (OH_NativeXComponent *component, bool needSoftKeyboard) 为此OH_NativeXComponent实例设置是否需要软键盘。
int32_t OH_NativeXComponent_RegisterSurfaceShowCallback (OH_NativeXComponent *component, void(*callback)(OH_NativeXComponent *component, void *window)) 为此OH_NativeXComponent实例注册surface显示回调,该回调在应用从后台返回前台时触发。
int32_t OH_NativeXComponent_RegisterSurfaceHideCallback (OH_NativeXComponent *component, void(*callback)(OH_NativeXComponent *component, void *window)) 为此OH_NativeXComponent实例注册surface隐藏回调,该回调在应用从前台来到后台时触发。
int32_t OH_NativeXComponent_GetTouchEventSourceType (OH_NativeXComponent *component, int32_t pointId, OH_NativeXComponent_EventSourceType *sourceType) 获取ArkUI XComponent触发触摸事件的输入设备类型。
OH_NativeXComponent * OH_NativeXComponent_GetNativeXComponent (ArkUI_NodeHandle node) 基于Native接口创建的组件实例获取OH_NativeXComponent类型的指针。
int32_t OH_NativeXComponent_RegisterKeyEventCallbackWithResult (OH_NativeXComponent *component, bool(*callback)(OH_NativeXComponent *component, void *window)) 为此OH_NativeXComponent实例注册有返回值的按键事件回调。
int32_t OH_ArkUI_XComponent_StartImageAnalyzer (ArkUI_NodeHandle node, void *userData,void (*callback)(ArkUI_NodeHandle node, ArkUI_XComponent_ImageAnalyzerState statusCode, void *userData)) 为此XComponent组件实例开始图像AI分析。
int32_t OH_ArkUI_XComponent_StopImageAnalyzer(ArkUI_NodeHandle node) 为此XComponent组件实例停止图像AI分析。
OH_ArkUI_SurfaceCallback* OH_ArkUI_SurfaceCallback_Create() 创建OH_ArkUI_SurfaceCallback对象。
void OH_ArkUI_SurfaceCallback_Dispose(OH_ArkUI_SurfaceCallback* callback) 销毁OH_ArkUI_SurfaceCallback对象。
OH_ArkUI_SurfaceHolder* OH_ArkUI_SurfaceHolder_Create(ArkUI_NodeHandle node) 创建XComponent组件的OH_ArkUI_SurfaceHolder对象。
void OH_ArkUI_SurfaceHolder_Dispose(OH_ArkUI_SurfaceHolder* surfaceHolder) 销毁OH_ArkUI_SurfaceHolder对象。
int32_t OH_NativeXComponent_GetExtraMouseEventInfo(OH_NativeXComponent* component, OH_NativeXComponent_ExtraMouseEventInfo** extraMouseEventInfo) 从此OH_NativeXComponent实例中获取扩展的鼠标事件信息。
int32_t OH_NativeXComponent_GetMouseEventModifierKeyStates(OH_NativeXComponent_ExtraMouseEventInfo* ExtraMouseEventInfo, uint64_t* keys) 从OH_NativeXComponent_ExtraMouseEventInfo实例中获取功能键按压状态信息。
int32_t OH_NativeXComponent_GetKeyEventModifierKeyStates(OH_NativeXComponent_KeyEvent* keyEvent, uint64_t* keys) 从按键事件中获取功能键按压状态。
int32_t OH_NativeXComponent_GetKeyEventNumLockState(OH_NativeXComponent_KeyEvent* keyEvent, bool* isNumLockOn) 从按键事件中获取NumLock(小键盘锁定)键的状态。
int32_t OH_NativeXComponent_GetKeyEventCapsLockState(OH_NativeXComponent_KeyEvent* keyEvent, bool* isCapsLockOn) 从按键事件中获取CapsLock(大写锁定)键的状态。
int32_t OH_NativeXComponent_GetKeyEventScrollLockState(OH_NativeXComponent_KeyEvent* keyEvent, bool* isScrollLockOn) 从按键事件中获取ScrollLock(滚动锁定)键的状态。
int32_t OH_ArkUI_XComponent_SetExpectedFrameRateRange(ArkUI_NodeHandle node, OH_NativeXComponent_ExpectedRateRange range) 为此XComponent组件实例设置期望帧率。
int32_t OH_ArkUI_XComponent_RegisterOnFrameCallback(ArkUI_NodeHandle node,void (*callback)(ArkUI_NodeHandle node, uint64_t timestamp, uint64_t targetTimestamp)) 为此XComponent组件实例注册帧回调函数。
int32_t OH_ArkUI_XComponent_UnregisterOnFrameCallback(ArkUI_NodeHandle node) 为此XComponent组件实例取消注册帧回调函数。
int32_t OH_ArkUI_XComponent_SetNeedSoftKeyboard(ArkUI_NodeHandle node, bool needSoftKeyboard) 为此XComponent组件实例设置是否需要软键盘。
ArkUI_AccessibilityProvider* OH_ArkUI_AccessibilityProvider_Create(ArkUI_NodeHandle node) 基于此XComponent组件实例创建ArkUI_AccessibilityProvider实例。
void OH_ArkUI_AccessibilityProvider_Dispose(ArkUI_AccessibilityProvider* provider) 销毁由NDK接口OH_ArkUI_AccessibilityProvider_Create创建的ArkUI_AccessibilityProvider实例。
void OH_ArkUI_SurfaceCallback_SetSurfaceShowEvent(OH_ArkUI_SurfaceCallback* callback,void (*onSurfaceShow)(OH_ArkUI_SurfaceHolder* surfaceHolder)) 为此OH_ArkUI_SurfaceCallback实例设置Surface显示回调。
void OH_ArkUI_SurfaceCallback_SetSurfaceHideEvent(OH_ArkUI_SurfaceCallback* callback,void (*onSurfaceHide)(OH_ArkUI_SurfaceHolder* surfaceHolder)) 为此OH_ArkUI_SurfaceCallback实例设置Surface隐藏回调。
int32_t OH_ArkUI_SurfaceHolder_SetUserData(OH_ArkUI_SurfaceHolder* surfaceHolder,void* userData) 向OH_ArkUI_SurfaceHolder实例存储自定义数据。
void* OH_ArkUI_SurfaceHolder_GetUserData(OH_ArkUI_SurfaceHolder* surfaceHolder) 获取OH_ArkUI_SurfaceHolder实例存储的自定义数据。
void OH_ArkUI_SurfaceCallback_SetSurfaceCreatedEvent(OH_ArkUI_SurfaceCallback* callback,void (*onSurfaceCreated)(OH_ArkUI_SurfaceHolder* surfaceHolder)) 设置surface生命周期回调中的创建回调事件。
void OH_ArkUI_SurfaceCallback_SetSurfaceChangedEvent(OH_ArkUI_SurfaceCallback* callback,void (*onSurfaceChanged)(OH_ArkUI_SurfaceHolder* surfaceHolder,uint64_t width,uint64_t height)) 设置surface生命周期回调中的大小改变回调事件。
void OH_ArkUI_SurfaceCallback_SetSurfaceDestroyedEvent(OH_ArkUI_SurfaceCallback* callback,void (*onSurfaceDestroyed)(OH_ArkUI_SurfaceHolder* surfaceHolder)) 设置surface生命周期回调中的销毁回调事件。
int32_t OH_ArkUI_SurfaceHolder_AddSurfaceCallback(OH_ArkUI_SurfaceHolder* surfaceHolder,OH_ArkUI_SurfaceCallback* callback) 添加surface生命周期回调到OH_ArkUI_SurfaceHolder实例。
int32_t OH_ArkUI_SurfaceHolder_RemoveSurfaceCallback(OH_ArkUI_SurfaceHolder* surfaceHolder,OH_ArkUI_SurfaceCallback* callback) 删除OH_ArkUI_SurfaceHolder实例的先前添加的surface生命周期回调。
OHNativeWindow* OH_ArkUI_XComponent_GetNativeWindow(OH_ArkUI_SurfaceHolder* surfaceHolder) 获取OH_ArkUI_SurfaceHolder实例关联的nativeWindow。
int32_t OH_ArkUI_XComponent_SetAutoInitialize(ArkUI_NodeHandle node,bool autoInitialize) 设置XComponent组件是否需要自动初始化的标志位。
int32_t OH_ArkUI_XComponent_Initialize(ArkUI_NodeHandle node) 初始化XComponent组件持有的surface。
int32_t OH_ArkUI_XComponent_Finalize(ArkUI_NodeHandle node) 销毁XComponent组件持有的surface。
int32_t OH_ArkUI_XComponent_IsInitialized(ArkUI_NodeHandle node, bool* isInitialized) 获取XComponent组件是否已经初始化的标志位。

变量

名称 描述
const uint32_t OH_XCOMPONENT_ID_LEN_MAX = 128 ArkUI XComponent的id的最大长度。
const uint32_t OH_MAX_TOUCH_POINTS_NUMBER = 10 触摸事件中的可识别的触摸点个数最大值。

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkUI(方舟UI框架)

harmony 鸿蒙ARKUI_TextPickerCascadeRangeContent

harmony 鸿蒙ARKUI_TextPickerRangeContent

harmony 鸿蒙ArkUI_AnimateCompleteCallback

harmony 鸿蒙ArkUI_AttributeItem

harmony 鸿蒙ArkUI_ColorStop

harmony 鸿蒙ArkUI_ContextCallback

harmony 鸿蒙ArkUI_EventModule

harmony 鸿蒙ArkUI_ExpectedFrameRateRange

harmony 鸿蒙ArkUI_IntOffset

0  赞