• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Immersive Mode of the Input Method Application
2
3
4## When to Use
5
6To implement consistent immersive experience, a communication mechanism between foreground applications and input method applications is provided. You can set the immersive input mode based on the immersive mode of the foreground application.
7
8## Working Principles
9![Immersive mode of the input method](./figures/immersive-mode-of-the-input-method.png)
10- The foreground application sets the desired immersive mode based on the application scenario.
11- The desired immersive mode of the foreground application is then passed to the input method application through the input method framework.
12- The input method application determines the final immersive mode for the input method framework based on the immersive mode of the foreground application.
13
14## Access Guide
151. The foreground application [sets the immersive mode for the text box](../reference/apis-arkui/arkui-ts/ts-basic-components-textarea.md#keyboardappearance15). The sample code is as follows:
16   ```ts
17   TextArea({text: "hello world"})
18      .keyboardAppearance(KeyboardAppearance.IMMERSIVE)
19   ```
20
212. The input method application [subscribes to the text box attribute change event](../reference/apis-ime-kit/js-apis-inputmethodengine.md#oneditorattributechanged10) and detects the immersive mode desired by the foreground application through the **immersiveMode** field in the **EditorAttribute** callback. The sample code is as follows:
22
23   ```ts
24   import { inputMethodEngine } from '@kit.IMEKit';
25
26   inputMethodEngine.getKeyboardDelegate().on("editorAttributeChanged", (attr : inputMethodEngine.EditorAttribute) => {
27      console.log("recv editorAttributeChanged, immersiveMode: " + attr.immersiveMode);
28   })
29   ```
30
313. The input method application [sets the immersive mode](../reference/apis-ime-kit/js-apis-inputmethodengine.md#setimmersivemode15).
32   - The **IMMERSIVE** mode is determined by the input method application.
33   - The input method application cannot set the **IMMERSIVE** mode to the input method framework.
34   - If the input method application receives **IMMERSIVE** from the foreground application, it is recommended that the input method application set the final immersive mode to **LIGHT_IMMERSIVE** or **DARK_IMMERSIVE** based on the current system color mode.
35
36
37   The following sample code shows how to set the immersive mode:
38   ```ts
39   panel.setImmersiveMode(inputMethodEngine.ImmersiveMode.LIGHT_IMMERSIVE);
40   ```
41