openharmony 鸿蒙 capi-native-interface-focus-h

2026-08-25 浏览 (1)

native_interface_focus.h

Overview

Declares APIs for focus management, mainly used for actively transferring focus, managing the default focus transfer behavior, and controlling the focus activation state.

File to include: <arkui/native_interface_focus.h>

Library: libace_ndk.z.so

System capability: SystemCapability.ArkUI.ArkUI.Full

Since: 15

Related module: ArkUI_NativeModule

Sample: NdkFocus

Summary

Enums

Nametypedef KeywordDescription
ArkUI_KeyProcessingModeArkUI_KeyProcessingModeEnumerates the key event processing priority modes.

Functions

NameDescription
ArkUI_ErrorCode OH_ArkUI_FocusRequest(ArkUI_NodeHandle node)Requests focus for a specific node.
void OH_ArkUI_FocusClear(ArkUI_ContextHandle uiContext)Clears the focus to the root container node.
void OH_ArkUI_FocusActivate(ArkUI_ContextHandle uiContext, bool isActive, bool isAutoInactive)Sets the focus activation state for the current page. When activated, the focused node displays a focus box.
void OH_ArkUI_FocusSetAutoTransfer(ArkUI_ContextHandle uiContext, bool autoTransfer)Configures the focus transfer behavior when pages are switched.
void OH_ArkUI_FocusSetKeyProcessingMode(ArkUI_ContextHandle uiContext, ArkUI_KeyProcessingMode mode)Sets the mode for processing key events.

Enum Description

ArkUI_KeyProcessingMode

enum ArkUI_KeyProcessingMode

Description

Enumerates the key event processing priority modes.

Since: 15

ValueDescription
ARKUI_KEY_PROCESSING_MODE_FOCUS_NAVIGATION = 0Key events are used for focus navigation.
ARKUI_KEY_PROCESSING_MODE_FOCUS_ANCESTOR_EVENT = 1Key events are passed up to ancestor components.

Function Description

OH_ArkUI_FocusRequest()

ArkUI_ErrorCode OH_ArkUI_FocusRequest(ArkUI_NodeHandle node)

Description

Requests focus for a specific node.

Since: 15

Parameters

NameDescription
ArkUI_NodeHandle nodeNode.

Return value

TypeDescription
ArkUI_ErrorCodeResult code.
Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful.
Returns ARKUI_ERROR_CODE_FOCUS_NON_FOCUSABLE if the node cannot receive focus.
Returns ARKUI_ERROR_CODE_FOCUS_NON_FOCUSABLE_ANCESTOR if the ancestor node cannot receive focus.
Returns ARKUI_ERROR_CODE_FOCUS_NON_EXISTENT if the node does not exist.

OH_ArkUI_FocusClear()

void OH_ArkUI_FocusClear(ArkUI_ContextHandle uiContext)

Description

Clears the focus to the root container node.

Since: 15

Parameters

NameDescription
ArkUI_ContextHandle uiContextUI instance object pointer.

OH_ArkUI_FocusActivate()

void OH_ArkUI_FocusActivate(ArkUI_ContextHandle uiContext, bool isActive, bool isAutoInactive)

Description

Sets the focus activation state for the current page. When activated, the focused node displays a focus box.

Since: 15

Parameters

NameDescription
ArkUI_ContextHandle uiContextUI instance object pointer.
bool isActiveWhether to enter or exit the focus activation state. The value true means to enter the focus activation state, and false means to exit the focus activation state.
bool isAutoInactiveWhether to automatically exit the focus active state on touch or mouse down events. true: Automatically exit the focus active state. false: Maintain the current state until the corresponding setting API is called.

OH_ArkUI_FocusSetAutoTransfer()

void OH_ArkUI_FocusSetAutoTransfer(ArkUI_ContextHandle uiContext, bool autoTransfer)

Description

Configures the focus transfer behavior when pages are switched.

Since: 15

Parameters

NameDescription
ArkUI_ContextHandle uiContextUI instance object pointer.
bool autoTransferWhether to automatically transfer focus when pages are switched. The value true means to automatically transfer focus when pages are switched, and false means the opposite.

OH_ArkUI_FocusSetKeyProcessingMode()

void OH_ArkUI_FocusSetKeyProcessingMode(ArkUI_ContextHandle uiContext, ArkUI_KeyProcessingMode mode)

Description

Sets the mode for processing key events.

Since: 15

Parameters

NameDescription
ArkUI_ContextHandle uiContextUI instance object pointer.
ArkUI_KeyProcessingMode modeKey event processing priority mode.

你可能感兴趣的鸿蒙文章

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