目录

@ohos.inputMethod.Panel (Input Method Panel)

The @ohos.inputMethod.Panel module provides data definitions for input method panel attributes, supporting configuration of the panel type and display state. It is applicable to scenarios that require fine-grained control over the display behavior of the input method panel.

This module serves as a data module for input method panel attributes. It defines the PanelInfo interface and two enum types, PanelType and PanelFlag, to specify the input method panel type (soft keyboard or status bar) and display state (fixed, floating, or candidate).

This module offers capabilities to configure input method panel attributes. An input method app can specify the panel type and state via PanelInfo to implement panels in different forms: fixed soft keyboard (default, anchored at the bottom of the screen), floating soft keyboard (freely draggable), and candidate panel (displays candidate words in an independent window, with visibility controlled by you).

Use this module when an input method app needs to create and configure an input method panel. Typical scenarios include creating a default fixed soft keyboard panel, creating a floating keyboard that supports free dragging, or creating a candidate word panel to show input candidates.

The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version.

The data type must be used in combination with the APIs of the @ohos.inputMethodEngine module. Pass PanelInfo when creating a panel using InputMethodAbility.createPanel(), to specify the panel type and state. Typical usage process: construct PanelInfo → pass it through createPanel() → the system creates a panel of the corresponding type accordingly. Different PanelFlag values correspond to distinct panel behaviors: a fixed panel stays anchored at the screen bottom, a floating panel can be dragged freely, and the visibility of a candidate panel is controlled by you.

Key interfaces and enums defined in this module are as follows:

Interface/Type Description
PanelInfo Interface for input method panel attribute information. Contains two properties: type (panel type) and flag (panel state type, default value: FLAG_FIXED), used to describe the type and display form of an input method panel.
PanelType Enum for input method panel types, which defines panel categories: SOFT_KEYBOARD (soft keyboard, value 0) and STATUS_BAR (status bar, value 1).
PanelFlag Enum for input method panel state types, which defines panel display states: FLAG_FIXED (fixed, value 0), FLAG_FLOATING (floating, value 1), FLAG_CANDIDATE (candidate, value 2). The visibility of a candidate‑state panel is controlled by you.

This module is a pure data definition module. PanelInfo, as the panel attribute configuration, must be used in combination with APIs of other modules. A typical combination is: in the @ohos.inputMethodEngine module, pass PanelInfo to specify the panel type and state when creating a panel through InputMethodAbility.createPanel().

// The following is pseudocode for illustrating the calling logic.
import { PanelType, PanelFlag } from '@kit.IMEKit';

// 1. Configure attributes for a fixed soft‑keyboard panel.
let softKeyboardFixed = {
  type: PanelType.SOFT_KEYBOARD,
  flag: PanelFlag.FLAG_FIXED
};

// 2. Configure attributes for a floating soft‑keyboard panel.
let softKeyboardFloating = {
  type: PanelType.SOFT_KEYBOARD,
  flag: PanelFlag.FLAG_FLOATING
};

// 3. Configure attributes for a candidate‑state panel.
let candidatePanel = {
  type: PanelType.SOFT_KEYBOARD,
  flag: PanelFlag.FLAG_CANDIDATE
};

The visibility of a FLAG_CANDIDATE (candidate-state) panel is not controlled by the system. You need to manage the timing for showing and hiding the candidate word panel based on app scenarios.

Modules to Import

import { PanelInfo, PanelType, PanelFlag } from '@kit.IMEKit';

PanelInfo

Attribute information of the input method panel. It is used to describe the type and display state of the input method panel and is passed as a configuration parameter when you create an input method panel.

System capability: SystemCapability.MiscServices.InputMethodFramework

Name Type Read-Only Optional Description
type PanelType No No Input method panel type. Determines whether the panel is a soft keyboard or a status bar. When the parameter is not specified, the default value is SOFT_KEYBOARD (0).
flag PanelFlag No Yes

Input method panel state type.

- The default value is FLAG_FIXED (0), indicating a fixed-state panel type.

- Currently used only to describe the state of a soft-keyboard panel. Setting it for a STATUS_BAR type panel has no actual effect.

- The visibility behavior of the panel differs by state type. When the parameter is set to FLAG_FIXED or FLAG_FLOATING, panel visibility is controlled by the system. When the parameter is set to FLAG_CANDIDATE, panel visibility is controlled by you.

Suggestions for the PanelInfo parameter:

PanelType

Enumerates the input method panel types. Defines the panel category and determines whether the panel is a soft keyboard or a status bar.

System capability: SystemCapability.MiscServices.InputMethodFramework

Name Value Description Use Scenario
SOFT_KEYBOARD 0 Soft keyboard. Applies to scenarios that require keyboard input interaction. It is the primary panel type of an input method app. Most input method apps need to create at least one soft keyboard panel.
STATUS_BAR 1 Status bar. Applies to scenarios that require displaying input method status information (such as the current input language and input mode) at the top of the screen. It is usually used as an auxiliary panel together with the soft keyboard panel.

Suggestions for the PanelType parameter:

PanelFlag

Enumerates the input method panel state types. Defines the display form of a panel and determines whether the panel is in fixed, floating, or candidate state.

This enumeration applies only to SOFT_KEYBOARD panels. Setting PanelFlag for a STATUS_BAR panel takes no effect.

System capability: SystemCapability.MiscServices.InputMethodFramework

Name Value Description Usage Scenario Use Effect
FLAG_FIXED 0 Fixed-state panel type. Applies to most default input scenarios, where the panel is anchored at the bottom of the screen. The panel is displayed anchored at the bottom of the screen, and its visibility is managed by the system.
FLAG_FLOATING 1 Floating-state panel type. Applies to scenarios requiring free adjustment of the panel position (for example, landscape‑mode input, multi‑window environments, or tablet devices). The panel acts as a floating window that can be dragged freely, and its visibility is managed by the system.
FLAG_CANDIDATE 2

Candidate-word state panel type.

‑ When the input panel is in candidate-word state, it serves as a window for displaying user input candidates.

‑ The system does not actively control showing and hiding of the candidate‑word state panel. You need to control its visibility based on app scenarios.

Applies to scenarios that require independent display of candidate words, such as search association words and input suggestion lists. The panel is an independent candidate‑word window. You must control its visibility via Panel.show() and Panel.hide(). The system does not actively manage its visibility.

Suggestions for the PanelFlag parameter: