提交 f3c6bd0c 编写于 作者: E ester.zhou

Update docs (16300)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 31efd97d
...@@ -14,16 +14,19 @@ import InputMethodSubtype from '@ohos.InputMethodSubtype'; ...@@ -14,16 +14,19 @@ import InputMethodSubtype from '@ohos.InputMethodSubtype';
## Attributes ## Attributes
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**System capability**: SystemCapability.MiscServices.InputMethodFramework
| Name| Type| Readable| Writable| Mandatory| Description| | Name| Type| Readable| Writable| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- | -------- |
| label | string | Yes| No| No| Label of the input method subtype.| | label | string | Yes| No| No| Label of the input method subtype.|
| name | string | Yes| No| Yes| Name of the input method subtype.| | labelId<sup>10+</sup> | string | Yes| No| No| Label ID of the input method subtype.|
| name | string | Yes| No| Yes| Bundle name of the input method.|
| id | string | Yes| No| Yes| ID of the input method subtype.| | id | string | Yes| No| Yes| ID of the input method subtype.|
| mode | string | Yes| No| No| Mode of the input method subtype, including **upper** (uppercase) and **lower** (lowercase).| | mode | string | Yes| No| No| Mode of the input method subtype, including **upper** (uppercase) and **lower** (lowercase).|
| locale | string | Yes| No| Yes| Locale of the input method subtype.| | locale | string | Yes| No| Yes| Locale of the input method subtype.|
| language | string | Yes| No| Yes| Language of the input method subtype.| | language | string | Yes| No| Yes| Language of the input method subtype.|
| icon | string | Yes| No| No| Icon of the input method subtype.| | icon | string | Yes| No| No| Icon of the input method subtype.|
| iconId | number | Yes| No| No| Icon ID of the input method subtype.| | iconId | number | Yes| No| No| Icon ID of the input method subtype.|
| extra | object | Yes| Yes| Yes| Extra information of the input method subtype.| | extra | object | Yes| Yes| No| Extra information of the input method subtype.<br>**NOTE**<br>This parameter is optional since API version 10.|
# @ohos.inputMethod (Input Method Framework) # @ohos.inputMethod (Input Method Framework)
The **inputMethod** module provides an input method framework, which can be used to hide the keyboard, obtain the list of installed input methods, display the dialog box for input method selection, and more. The **inputMethod** module is oriented to common foreground applications (third-party applications and system applications such as Notes, Messaging, and Settings). It provides input method control and management capabilities, including displaying or hiding the soft keyboard, switching between input methods, and obtaining the list of all input methods.
> **NOTE** > **NOTE**
> >
...@@ -33,10 +33,11 @@ Describes the input method application attributes. ...@@ -33,10 +33,11 @@ Describes the input method application attributes.
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| name<sup>9+</sup> | string | Yes| No| Internal name of the input method. Mandatory.| | name<sup>9+</sup> | string | Yes| No| Internal name of the input method. Mandatory.|
| id<sup>9+</sup> | string | Yes| No| Unique ID of the input method. Mandatory.| | id<sup>9+</sup> | string | Yes| No| Unique ID of the input method. Mandatory.|
| label<sup>9+</sup> | string | Yes| No| External display name of the input method. Optional.| | label<sup>9+</sup> | string | Yes| No| External name of the input method. Optional.|
| labelId<sup>10+</sup> | string | Yes| No| External ID of the input method. Optional.|
| icon<sup>9+</sup> | string | Yes| No| Icon of the input method. Optional.| | icon<sup>9+</sup> | string | Yes| No| Icon of the input method. Optional.|
| iconId<sup>9+</sup> | number | Yes| No| Icon ID of the input method. Optional.| | iconId<sup>9+</sup> | number | Yes| No| Icon ID of the input method. Optional.|
| extra<sup>9+</sup> | object | Yes| Yes| Extra information about the input method. Mandatory.| | extra<sup>9+</sup> | object | Yes| Yes| Extra information about the input method. Optional.<br>**NOTE**<br>This parameter is optional since API version 10.|
| packageName<sup>(deprecated)</sup> | string | Yes| No| Name of the input method package. Mandatory.<br>**NOTE**<br>This API is supported since API version 8 and deprecated since API version 9. You are advised to use **name**.| | packageName<sup>(deprecated)</sup> | string | Yes| No| Name of the input method package. Mandatory.<br>**NOTE**<br>This API is supported since API version 8 and deprecated since API version 9. You are advised to use **name**.|
| methodId<sup>(deprecated)</sup> | string | Yes| No| Unique ID of the input method. Mandatory.<br>**NOTE**<br>This API is supported since API version 8 and deprecated since API version 9. You are advised to use **id**.| | methodId<sup>(deprecated)</sup> | string | Yes| No| Unique ID of the input method. Mandatory.<br>**NOTE**<br>This API is supported since API version 8 and deprecated since API version 9. You are advised to use **id**.|
...@@ -231,7 +232,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb ...@@ -231,7 +232,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb
Switches to another subtype of the current input method. This API uses an asynchronous callback to return the result. Switches to another subtype of the current input method. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.CONNECT_IME_ABILITY (available only to system applications) **Required permissions**: ohos.permission.CONNECT_IME_ABILITY (available only to system applications) <br>**NOTE**<br>Since API version 10, this permission is not required if the caller is the current input method.
**System capability**: SystemCapability.MiscServices.InputMethodFramework **System capability**: SystemCapability.MiscServices.InputMethodFramework
...@@ -239,7 +240,7 @@ Switches to another subtype of the current input method. This API uses an asynch ...@@ -239,7 +240,7 @@ Switches to another subtype of the current input method. This API uses an asynch
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| target | [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)| Yes| Input method subtype to switch to.| | target | [InputMethodSubtype](./js-apis-inputmethod-subtype.md)| Yes| Input method subtype to switch to.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.| | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -256,9 +257,9 @@ For details about the error codes, see [Input Method Framework Error Codes](../e ...@@ -256,9 +257,9 @@ For details about the error codes, see [Input Method Framework Error Codes](../e
```js ```js
try { try {
inputMethod.switchCurrentInputMethodSubtype({ inputMethod.switchCurrentInputMethodSubtype({
id: "com.example.kikakeyboard", id: "ServiceExtAbility",
label: "ServiceExtAbility", label: "",
name: "", name: "com.example.kikakeyboard",
mode: "upper", mode: "upper",
locale: "", locale: "",
language: "", language: "",
...@@ -287,7 +288,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise&lt;boolean& ...@@ -287,7 +288,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise&lt;boolean&
Switches to another subtype of the current input method. This API uses a promise to return the result. Switches to another subtype of the current input method. This API uses a promise to return the result.
**Required permissions**: ohos.permission.CONNECT_IME_ABILITY (available only to system applications) **Required permissions**: ohos.permission.CONNECT_IME_ABILITY (available only to system applications) <br>**NOTE**<br>Since API version 10, this permission is not required if the caller is the current input method.
**System capability**: SystemCapability.MiscServices.InputMethodFramework **System capability**: SystemCapability.MiscServices.InputMethodFramework
...@@ -295,7 +296,7 @@ Switches to another subtype of the current input method. This API uses a promise ...@@ -295,7 +296,7 @@ Switches to another subtype of the current input method. This API uses a promise
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
|target | [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)| Yes| Input method subtype to switch to.| |target | [InputMethodSubtype](./js-apis-inputmethod-subtype.md)| Yes| Input method subtype to switch to.|
**Return value** **Return value**
...@@ -317,9 +318,9 @@ For details about the error codes, see [Input Method Framework Error Codes](../e ...@@ -317,9 +318,9 @@ For details about the error codes, see [Input Method Framework Error Codes](../e
```js ```js
try { try {
inputMethod.switchCurrentInputMethodSubtype({ inputMethod.switchCurrentInputMethodSubtype({
id: "com.example.kikakeyboard", id: "ServiceExtAbility",
label: "ServiceExtAbility", label: "",
name: "", name: "com.example.kikakeyboard",
mode: "upper", mode: "upper",
locale: "", locale: "",
language: "", language: "",
...@@ -352,7 +353,7 @@ Obtains the current input method subtype. ...@@ -352,7 +353,7 @@ Obtains the current input method subtype.
| Type | Description | | Type | Description |
| -------------------------------------------- | ------------------------ | | -------------------------------------------- | ------------------------ |
| [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype) | Current input method subtype.| | [InputMethodSubtype](./js-apis-inputmethod-subtype.md) | Current input method subtype.|
**Example** **Example**
...@@ -375,7 +376,7 @@ Switches to a specified subtype of a specified input method. This API uses an as ...@@ -375,7 +376,7 @@ Switches to a specified subtype of a specified input method. This API uses an as
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
|inputMethodProperty | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.| |inputMethodProperty | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.|
|inputMethodSubtype | [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)| Yes| Input method subtype to switch to.| |inputMethodSubtype | [InputMethodSubtype](./js-apis-inputmethod-subtype.md)| Yes| Input method subtype to switch to.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.| | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -391,25 +392,9 @@ For details about the error codes, see [Input Method Framework Error Codes](../e ...@@ -391,25 +392,9 @@ For details about the error codes, see [Input Method Framework Error Codes](../e
```js ```js
let im = inputMethod.getCurrentInputMethod(); let im = inputMethod.getCurrentInputMethod();
let inputMethodProperty = { let imSubType = inputMethod.getCurrentInputMethodSubtype();
packageName: im.packageName,
methodId: im.methodId,
name: im.packageName,
id: im.methodId,
extra: {}
}
try { try {
inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, { inputMethod.switchCurrentInputMethodAndSubtype(im, imSubType, (err,result) => {
id: "com.example.kikakeyboard",
label: "ServiceExtAbility",
name: "",
mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
}, (err,result) => {
if (err !== undefined) { if (err !== undefined) {
console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err)); console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err));
return; return;
...@@ -440,7 +425,7 @@ Switches to a specified subtype of a specified input method. This API uses a pro ...@@ -440,7 +425,7 @@ Switches to a specified subtype of a specified input method. This API uses a pro
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
|inputMethodProperty | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.| |inputMethodProperty | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.|
|inputMethodSubtype | [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)| Yes| Input method subtype to switch to.| |inputMethodSubtype | [InputMethodSubtype](./js-apis-inputmethod-subtype.md)| Yes| Input method subtype to switch to.|
**Return value** **Return value**
...@@ -461,25 +446,9 @@ For details about the error codes, see [Input Method Framework Error Codes](../e ...@@ -461,25 +446,9 @@ For details about the error codes, see [Input Method Framework Error Codes](../e
```js ```js
let im = inputMethod.getCurrentInputMethod(); let im = inputMethod.getCurrentInputMethod();
let inputMethodProperty = { let imSubType = inputMethod.getCurrentInputMethodSubtype();
packageName: im.packageName,
methodId: im.methodId,
name: im.packageName,
id: im.methodId,
extra: {}
}
try { try {
inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, { inputMethod.switchCurrentInputMethodAndSubtype(im, imSubType).then((result) => {
id: im.packageName,
label: im.methodId,
name: "",
mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
}).then((result) => {
if (result) { if (result) {
console.info('Succeeded in switching currentInputMethodAndSubtype.'); console.info('Succeeded in switching currentInputMethodAndSubtype.');
} else { } else {
...@@ -886,7 +855,7 @@ inputMethodController.off('selectByRange'); ...@@ -886,7 +855,7 @@ inputMethodController.off('selectByRange');
on(type: 'selectByMovement', callback: Callback&lt;Movement&gt;): void on(type: 'selectByMovement', callback: Callback&lt;Movement&gt;): void
Enables listening for the selection-by-cursor-movement event. This API uses an asynchronous callback to return the result. Enables listening for the select-by-cursor-movement event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework **System capability**: SystemCapability.MiscServices.InputMethodFramework
...@@ -894,7 +863,7 @@ Enables listening for the selection-by-cursor-movement event. This API uses an a ...@@ -894,7 +863,7 @@ Enables listening for the selection-by-cursor-movement event. This API uses an a
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **selectByMovement** indicates the selection-by-cursor-movement event.| | type | string | Yes | Listening type.<br>The value **selectByMovement** indicates the select-by-cursor-movement event.|
| callback | Callback&lt;[Movement](./js-apis-inputmethod-InputMethodCommon.md#movement)&gt; | Yes | Callback used to return the range of the text to be selected.<br>Your application needs to select the text in the returned range in the text box.| | callback | Callback&lt;[Movement](./js-apis-inputmethod-InputMethodCommon.md#movement)&gt; | Yes | Callback used to return the range of the text to be selected.<br>Your application needs to select the text in the returned range in the text box.|
**Example** **Example**
...@@ -909,7 +878,7 @@ inputMethodController.on('selectByMovement', (movement) => { ...@@ -909,7 +878,7 @@ inputMethodController.on('selectByMovement', (movement) => {
off(type: 'selectByMovement'): void off(type: 'selectByMovement'): void
Disables listening for the selection-by-cursor-movement event. Disables listening for the select-by-cursor-movement event.
**System capability**: SystemCapability.MiscServices.InputMethodFramework **System capability**: SystemCapability.MiscServices.InputMethodFramework
...@@ -917,7 +886,7 @@ Disables listening for the selection-by-cursor-movement event. ...@@ -917,7 +886,7 @@ Disables listening for the selection-by-cursor-movement event.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ | | ------ | ------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **selectByMovement** indicates the selection-by-cursor-movement event.| | type | string | Yes | Listening type.<br>The value **selectByMovement** indicates the select-by-cursor-movement event.|
**Example** **Example**
...@@ -942,7 +911,7 @@ Enables listening for the input method and subtype change event. This API uses a ...@@ -942,7 +911,7 @@ Enables listening for the input method and subtype change event. This API uses a
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'imeChange'** indicates the input method and subtype change event.| | type | string | Yes | Listening type.<br>The value **'imeChange'** indicates the input method and subtype change event.|
| callback | (inputMethodProperty: [InputMethodProperty](#inputmethodproperty8), inputMethodSubtype: [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)) => void | Yes| Callback used to return the input method attributes and subtype.| | callback | (inputMethodProperty: [InputMethodProperty](#inputmethodproperty8), inputMethodSubtype: [InputMethodSubtype](./js-apis-inputmethod-subtype.md)) => void | Yes| Callback used to return the input method attributes and subtype.|
**Example** **Example**
...@@ -965,7 +934,7 @@ Disables listening for the input method and subtype change event. This API uses ...@@ -965,7 +934,7 @@ Disables listening for the input method and subtype change event. This API uses
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'imeChange'** indicates the input method and subtype change event.| | type | string | Yes | Listening type.<br>The value **'imeChange'** indicates the input method and subtype change event.|
| callback | (inputMethodProperty: [InputMethodProperty](#inputmethodproperty8), inputMethodSubtype: [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)) => void | No| Callback used to return the input method attributes and subtype.| | callback | (inputMethodProperty: [InputMethodProperty](#inputmethodproperty8), inputMethodSubtype: [InputMethodSubtype](./js-apis-inputmethod-subtype.md)) => void | No| Callback used to return the input method attributes and subtype.|
**Example** **Example**
...@@ -986,7 +955,7 @@ Obtains all subtypes of a specified input method. This API uses an asynchronous ...@@ -986,7 +955,7 @@ Obtains all subtypes of a specified input method. This API uses an asynchronous
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------------------- | ---- | ---------------------- | | -------- | -------------------------------------------------- | ---- | ---------------------- |
| inputMethodProperty | InputMethodProperty| Yes| Input method to which the subtypes belong.| | inputMethodProperty | InputMethodProperty| Yes| Input method to which the subtypes belong.|
| callback | AsyncCallback&lt;Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)>&gt; | Yes| Callback used to return all subtypes of the specified input method.| | callback | AsyncCallback&lt;Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md)>&gt; | Yes| Callback used to return all subtypes of the specified input method.|
**Error codes** **Error codes**
...@@ -1038,7 +1007,7 @@ Obtains all subtypes of a specified input method. This API uses a promise to ret ...@@ -1038,7 +1007,7 @@ Obtains all subtypes of a specified input method. This API uses a promise to ret
| Type | Description | | Type | Description |
| ----------------------------------------------------------- | ---------------------- | | ----------------------------------------------------------- | ---------------------- |
| Promise<Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)>> | Promise used to return all subtypes of the specified input method.| | Promise<Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md)>> | Promise used to return all subtypes of the specified input method.|
**Error codes** **Error codes**
...@@ -1082,7 +1051,7 @@ Obtains all subtypes of this input method. This API uses an asynchronous callbac ...@@ -1082,7 +1051,7 @@ Obtains all subtypes of this input method. This API uses an asynchronous callbac
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------------------- | ---- | ---------------------- | | -------- | -------------------------------------------------- | ---- | ---------------------- |
| callback | AsyncCallback&lt;Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)>&gt; | Yes | Callback used to return all subtypes of the current input method.| | callback | AsyncCallback&lt;Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md)>&gt; | Yes | Callback used to return all subtypes of the current input method.|
**Error codes** **Error codes**
...@@ -1121,7 +1090,7 @@ Obtains all subtypes of this input method. This API uses a promise to return the ...@@ -1121,7 +1090,7 @@ Obtains all subtypes of this input method. This API uses a promise to return the
| Type | Description | | Type | Description |
| ----------------------------------------------------------- | ---------------------- | | ----------------------------------------------------------- | ---------------------- |
| Promise<Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)>> | Promise used to return all subtypes of the current input method.| | Promise<Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md)>> | Promise used to return all subtypes of the current input method.|
**Error codes** **Error codes**
......
# @ohos.inputMethodEngine (Input Method Service) # @ohos.inputMethodEngine (Input Method Service)
The **inputMethodEngine** module streamlines the interactions between input methods and applications. By calling APIs of this module, applications can be bound to input method services to accept text input, request the keyboard to display or hide, listen for the input method status, and much more. The **inputMethodEngine** module is oriented to input method applications (including system and third-party input method applications). With the APIs of this module, input method applications are able to create soft keyboard windows, insert or delete characters, select text, and listen for physical keyboard events.
> **NOTE** > **NOTE**
> >
...@@ -56,15 +56,15 @@ Provides the constant values of function keys, edit boxes, and the cursor. ...@@ -56,15 +56,15 @@ Provides the constant values of function keys, edit boxes, and the cursor.
getInputMethodAbility(): InputMethodAbility getInputMethodAbility(): InputMethodAbility
Obtains an **InputMethodEngine** instance. Obtains an [InputMethodAbility](#inputmethodability) instance for the input method. The input method can use the obtained instance to subscribe to a soft keyboard display/hide request event, create/destroy an input method panel, and the like.
**System capability**: SystemCapability.MiscServices.InputMethodFramework **System capability**: SystemCapability.MiscServices.InputMethodFramework
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------------- | ------------ | | ----------------------------------------- | ------------------ |
| [InputMethodAbility](#inputmethodability) | **InputMethodEngine** instance obtained.| | [InputMethodAbility](#inputmethodability) | **InputMethodAbility** instance.|
**Example** **Example**
...@@ -76,15 +76,15 @@ let InputMethodAbility = inputMethodEngine.getInputMethodAbility(); ...@@ -76,15 +76,15 @@ let InputMethodAbility = inputMethodEngine.getInputMethodAbility();
getKeyboardDelegate(): KeyboardDelegate getKeyboardDelegate(): KeyboardDelegate
Obtains a **KeyboardDelegate** instance. Obtains a [KeyboardDelegate](#keyboarddelegate) instance for the input method. The input method can use the obtained instance to subscribe to a physical keyboard event, text selection change event, and more.
**System capability**: SystemCapability.MiscServices.InputMethodFramework **System capability**: SystemCapability.MiscServices.InputMethodFramework
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------------- | ---------------- | | ------------------------------------- | ------------------------ |
| [KeyboardDelegate](#keyboarddelegate) | **KeyboardDelegate** instance obtained.| | [KeyboardDelegate](#keyboarddelegate) | **KeyboardDelegate** instance.|
**Example** **Example**
...@@ -96,7 +96,7 @@ let KeyboardDelegate = inputMethodEngine.getKeyboardDelegate(); ...@@ -96,7 +96,7 @@ let KeyboardDelegate = inputMethodEngine.getKeyboardDelegate();
getInputMethodEngine(): InputMethodEngine getInputMethodEngine(): InputMethodEngine
Obtains an **InputMethodEngine** instance. Obtains an [InputMethodEngine](#inputmethodengine-1) instance for the input method. The input method can use the obtained instance to subscribe to a soft keyboard display/hide request event.
> **NOTE** > **NOTE**
> >
...@@ -107,8 +107,8 @@ Obtains an **InputMethodEngine** instance. ...@@ -107,8 +107,8 @@ Obtains an **InputMethodEngine** instance.
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------------- | ------------ | | ----------------------------------------- | ------------------ |
| [InputMethodEngine](#inputmethodengine-1) | **InputMethodEngine** instance obtained.| | [InputMethodEngine](#inputmethodengine-1) | **InputMethodAbility** instance.|
**Example** **Example**
...@@ -120,7 +120,7 @@ let InputMethodEngine = inputMethodEngine.getInputMethodEngine(); ...@@ -120,7 +120,7 @@ let InputMethodEngine = inputMethodEngine.getInputMethodEngine();
createKeyboardDelegate(): KeyboardDelegate createKeyboardDelegate(): KeyboardDelegate
Obtains a **KeyboardDelegate** instance. Obtains a [KeyboardDelegate](#keyboarddelegate) instance for the input method. The input method can use the obtained instance to subscribe to a physical keyboard event, text selection change event, and more.
> **NOTE** > **NOTE**
> >
...@@ -131,8 +131,8 @@ Obtains a **KeyboardDelegate** instance. ...@@ -131,8 +131,8 @@ Obtains a **KeyboardDelegate** instance.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------------- | ---------------- | | ------------------------------------- | ------------------------ |
| [KeyboardDelegate](#keyboarddelegate) | **KeyboardDelegate** instance obtained.| | [KeyboardDelegate](#keyboarddelegate) | **KeyboardDelegate** instance.|
**Example** **Example**
...@@ -157,7 +157,7 @@ Enables listening for the input method binding event. This API uses an asynchron ...@@ -157,7 +157,7 @@ Enables listening for the input method binding event. This API uses an asynchron
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'inputStart'** indicates the input method binding event.| | type | string | Yes | Listening type.<br>The value **'inputStart'** indicates the input method binding event.|
| callback | (kbController: [KeyboardController](#keyboardcontroller), textInputClient: [TextInputClient](#textinputclient)) => void | Yes| Callback used to return the **KeyboardController** and **TextInputClient** instances.| | callback | (kbController: [KeyboardController](#keyboardcontroller), textInputClient: [TextInputClient](#textinputclientdeprecated)) => void | Yes| Callback used to return the **KeyboardController** and **TextInputClient** instances.|
**Example** **Example**
...@@ -181,7 +181,7 @@ Cancels listening for the input method binding event. ...@@ -181,7 +181,7 @@ Cancels listening for the input method binding event.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------ | | -------- | -------------------- | ---- | ------------------------ |
| type | string | Yes | Listening type.<br>The value **'inputStart'** indicates the input method binding event.| | type | string | Yes | Listening type.<br>The value **'inputStart'** indicates the input method binding event.|
| callback | (kbController: [KeyboardController](#keyboardcontroller), textInputClient: [TextInputClient](#textinputclient)) => void | No| Callback used to return the **KeyboardController** and **TextInputClient** instances.| | callback | (kbController: [KeyboardController](#keyboardcontroller), textInputClient: [TextInputClient](#textinputclientdeprecated)) => void | No| Callback used to return the **KeyboardController** and **TextInputClient** instances.|
**Example** **Example**
...@@ -195,7 +195,7 @@ inputMethodEngine.getInputMethodEngine().off('inputStart', (kbController, textIn ...@@ -195,7 +195,7 @@ inputMethodEngine.getInputMethodEngine().off('inputStart', (kbController, textIn
on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void
Enables listening for a keyboard event. This API uses an asynchronous callback to return the result. Enables listening for a keyboard visibility event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework **System capability**: SystemCapability.MiscServices.InputMethodFramework
...@@ -221,7 +221,7 @@ inputMethodEngine.getInputMethodEngine().on('keyboardHide', () => { ...@@ -221,7 +221,7 @@ inputMethodEngine.getInputMethodEngine().on('keyboardHide', () => {
off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void
Disables listening for a keyboard event. This API uses an asynchronous callback to return the result. Disables listening for a keyboard visibility event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework **System capability**: SystemCapability.MiscServices.InputMethodFramework
...@@ -478,6 +478,186 @@ inputMethodEngine.getInputMethodAbility().off('setSubtype', () => { ...@@ -478,6 +478,186 @@ inputMethodEngine.getInputMethodAbility().off('setSubtype', () => {
}); });
``` ```
### createPanel<sup>10+</sup>
createPanel(ctx: BaseContext, info: PanelInfo, callback: AsyncCallback\<Panel>): void
Creates an input method panel. This API can be called only by input method applications and system applications with the system_core permission. Only one SOFT_KEYBOARD panel and one STATUS_BAR panel can be created for a single input method application. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ----------- | ---- | ------------------------ |
| ctx | [BaseContext](./js-apis-inner-application-baseContext.md) | Yes | Context of the current input method.|
| info | [PanelInfo](#panelinfo10) | Yes | Information about the input method panel.|
| callback | AsyncCallback\<[Panel](#panel10)> | Yes | Callback used to return the result. If the operation is successful, the created input method panel is returned. |
**Error codes**
| Error Code ID | Error Message |
| ---------- | ----------------------------- |
| 12800004 | not an input method extension |
**Example**
```js
let panelInfo: inputMethodEngine.PanelInfo = {
panelType: SOFT_KEYBOARD,
panelFlag: FLG_FIXED
}
try {
inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => {
if (err !== undefined) {
console.log('Failed to create panel, err: ' + JSON.stringify(err));
return;
}
console.log('Succeed in creating panel.');
})
} catch(err) {
console.log('Failed to create panel, err: ' + JSON.stringify(err));
}
```
### createPanel<sup>10+</sup>
createPanel(ctx: BaseContext, info: PanelInfo): Promise\<Panel>
Creates an input method panel. This API can be called only by input method applications and system applications with the system_core permission. Only one SOFT_KEYBOARD panel and one STATUS_BAR panel can be created for a single input method application. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ----------- | ---- | ------------------------ |
| ctx | [BaseContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-inner-application-baseContext.md) | Yes | Context of the current input method.|
| info | [PanelInfo](#panelinfo10) | Yes | Information about the input method panel.|
**Return value**
| Type | Description |
| ------- | ------------------------------------------------------------------ |
| Promise\<[Panel](#panel10)> | Promise used to return the result. If the operation is successful, the created input method panel is returned. |
**Error codes**
| Error Code ID | Error Message |
| ---------- | ----------------------------- |
| 12800004 | not an input method extension |
**Example**
```js
let panelInfo: inputMethodEngine.PanelInfo = {
panelType: SOFT_KEYBOARD,
panelFlag: FLG_FIXED
}
inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo).then((panel) => {
console.log('Succeed in creating panel.');
}).catch((err) => {
console.log('Failed to create panel, err: ' + JSON.stringify(err));
})
```
### destroyPanel<sup>10+</sup>
destroyPanel(panel: Panel, callback: AsyncCallback\<void>): void;
Destroys an input method panel. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ----------- | ---- | ------------------------ |
| panel | [Panel](#panel10) | Yes | Input method panel to destroy.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object. |
**Example**
```js
let panelInfo: inputMethodEngine.PanelInfo = {
panelType: SOFT_KEYBOARD,
panelFlag: FLG_FIXED
}
try {
inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => {
if (err !== undefined) {
console.log('Failed to create panel, err: ' + JSON.stringify(err));
return;
}
globalThis.inputMethodPanel = panel;
console.log('Succeed in creating panel.');
})
} catch(err) {
console.log('Failed to create panel, err: ' + JSON.stringify(err));
}
try {
inputMethodEngine.getInputMethodAbility().destroyPanel(globalThis.inputMethodPanel, (err) => {
if(err !== undefined) {
console.log('Failed to destroy panel, err: ' + JSON.stringify(err));
return;
}
console.log('Succeed in destroying panel.');
})
} catch(err) {
console.log('Failed to destroy panel, err: ' + JSON.stringify(err));
}
```
### destroyPanel<sup>10+</sup>
destroyPanel(panel: Panel): Promise\<void>;
Destroys an input method panel. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ---------| ----------- | ---- | ------------------------ |
| panel | [Panel](#panel10) | Yes | Input method panel to destroy. |
**Return value**
| Type | Description |
| ------- | -------------------------------------------------------------------- |
| Promise\<void> | Promise that returns no value.|
**Example**
```js
let panelInfo: inputMethodEngine.PanelInfo = {
panelType: SOFT_KEYBOARD,
panelFlag: FLG_FIXED
}
try {
inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => {
if (err !== undefined) {
console.log('Failed to create panel, err: ' + JSON.stringify(err));
return;
}
globalThis.inputMethodPanel = panel;
console.log('Succeed in creating panel.');
})
} catch(err) {
console.log('Failed to create panel, err: ' + JSON.stringify(err));
}
try {
inputMethodEngine.getInputMethodAbility().destroyPanel(globalThis.inputMethodPanel).then(() => {
console.log('Succeed in destroying panel.');
}).catch((err) => {
console.log('Failed to destroy panel, err: ' + JSON.stringify(err));
});
} catch (err) {
console.log('Failed to destroy panel, err: ' + JSON.stringify(err));
}
```
## KeyboardDelegate ## KeyboardDelegate
In the following API examples, you must first use **[getKeyboardDelegate](#inputmethodenginegetkeyboarddelegate9)** to obtain a **KeyboardDelegate** instance, and then call the APIs using the obtained instance. In the following API examples, you must first use **[getKeyboardDelegate](#inputmethodenginegetkeyboarddelegate9)** to obtain a **KeyboardDelegate** instance, and then call the APIs using the obtained instance.
...@@ -684,6 +864,455 @@ inputMethodEngine.getKeyboardDelegate().off('textChange', (text) => { ...@@ -684,6 +864,455 @@ inputMethodEngine.getKeyboardDelegate().off('textChange', (text) => {
}); });
``` ```
## Panel<sup>10+</sup>
In the following API examples, you must first use **[createPanel](#createpanel10)** to obtain a **Panel** instance, and then call the APIs using the obtained instance.
### setUiContent<sup>10+</sup>
setUiContent(path: string, callback: AsyncCallback\<void>): void
Loads content from a page to this panel. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- |
| path | string | Yes | Path of the page from which the content will be loaded.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
```js
try {
panel.setUiContent('pages/page2/page2', (err) => {
if (err) {
console.error('Failed to set the content. err:' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting the content.');
});
} catch (exception) {
console.error('Failed to set the content. err:' + JSON.stringify(exception));
}
```
### setUiContent<sup>10+</sup>
setUiContent(path: string): Promise\<void>
Loads content from a page to this panel. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- |
| path | string | Yes | Path of the page from which the content will be loaded.|
**Return value**
| Type | Description |
| ------- | ------------------------------ |
| Promise\<void> | Promise that returns no value. |
**Example**
```js
try {
let promise = panel.setUiContent('pages/page2/page2');
promise.then(() => {
console.info('Succeeded in setting the content.');
}).catch((err) =>{
console.error('Failed to set the content. err: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to set the content. err: ' + JSON.stringify(exception));
}
```
### setUiContent<sup>10+</sup>
setUiContent(path: string, storage: LocalStorage, callback: AsyncCallback\<void>): void
Loads content from a page linked to LocalStorage to this panel. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- |
| path | string | Yes | Path of the page from which the content will be loaded.|
| storage | [LocalStorage](../../quick-start/arkts-state-mgmt-application-level.md#localstorage) | Yes | Storage unit that provides storage for mutable and immutable state variables in the application.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
```js
let storage = new LocalStorage();
storage.setOrCreate('storageSimpleProp',121);
try {
panel.setUiContent('pages/page2/page2', storage, (err) => {
if (err) {
console.error('Failed to set the content. err:' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting the content.');
});
} catch (exception) {
console.error('Failed to set the content. err:' + JSON.stringify(exception));
}
```
### setUiContent<sup>10+</sup>
setUiContent(path: string, storage: LocalStorage): Promise\<void>
Loads content from a page linked to LocalStorage to this panel. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- |
| path | string | Yes | Path of the page from which the content will be loaded.|
| storage | [LocalStorage](../../quick-start/arkts-state-mgmt-application-level.md#localstorage) | Yes | Storage unit that provides storage for mutable and immutable state variables in the application.|
**Return value**
| Type | Description |
| ------- | ------------------------------ |
| Promise\<void> | Promise that returns no value. |
**Example**
```js
let storage = new LocalStorage();
storage.setOrCreate('storageSimpleProp',121);
try {
let promise = panel.setUiContent('pages/page2/page2');
promise.then(() => {
console.info('Succeeded in setting the content.');
}).catch((err) =>{
console.error('Failed to set the content. err: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to set the content. err: ' + JSON.stringify(exception));
}
```
### resize<sup>10+</sup>
resize(width: number, height: number, callback: AsyncCallback\<void>): void
Resizes this panel. This API uses an asynchronous callback to return the result.
The panel width cannot exceed the screen width, and the panel height cannot be higher than half of the screen height.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- |
| width | number | Yes | Target width of the panel, in pixels.|
| height | number | Yes | Target height of the panel, in pixels.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
```js
try {
panel.resize(500, 1000, (err) => {
if (err) {
console.error('Failed to change the panel size. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in changing the panel size.');
});
} catch (exception) {
console.error('Failed to change the panel size. Cause:' + JSON.stringify(exception));
}
```
### resize<sup>10+</sup>
resize(width: number, height: number): Promise\<void>;
Resizes this panel. This API uses a promise to return the result.
The panel width cannot exceed the screen width, and the panel height cannot be higher than half of the screen height.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- |
| width | number | Yes | Target width of the panel, in pixels.|
| height | number | Yes | Target height of the panel, in pixels.|
**Return value**
| Type | Description |
| ------- | ------------------------------ |
| Promise<void> | Promise that returns no value. |
**Example**
```js
try {
let promise = panel.resize(500, 1000);
promise.then(() => {
console.info('Succeeded in changing the panel size.');
}).catch((err) =>{
console.error('Failed to change the panel size. err: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to change the panel size. err: ' + JSON.stringify(exception));
}
```
### moveTo<sup>10+</sup>
moveTo(x: number, y: number, callback: AsyncCallback\<void>): void
Moves this panel to the specified position. This API uses an asynchronous callback to return the result.
This API does not work on panels in the FLG_FIXED state.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- |
| x | number | Yes | Distance to move along the x-axis, in px. A positive value indicates moving rightwards.|
| y | number | Yes | Distance to move along the y-axis, in pixels. A positive value indicates moving downwards.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
```js
try {
panel.moveTo(300, 300, (err) =>{
if (err) {
console.error('Failed to move the panel. err:' + JSON.stringify(err));
return;
}
console.info('Succeeded in moving the panel.');
});
} catch (exception) {
console.error('Failed to move the panel. err:' + JSON.stringify(exception));
}
```
### moveTo<sup>10+</sup>
moveTo(x: number, y: number): Promise\<void>
Moves this panel to the specified position. This API uses a promise to return the result.
This API does not work on panels in the FLG_FIXED state.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- |
| x | number | Yes | Distance to move along the x-axis, in pixels. A positive value indicates moving rightwards.|
| y | number | Yes | Distance to move along the y-axis, in pixels. A positive value indicates moving downwards.|
**Return value**
| Type | Description |
| ------- | ------------------------------ |
| Promise<void> | Promise that returns no value. |
**Example**
```js
try {
let promise = windowClass.moveTo(300, 300);
promise.then(() => {
console.info('Succeeded in moving the panel.');
}).catch((err) =>{
console.error('Failed to move the panel. Cause: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to move the panel. Cause:' + JSON.stringify(exception));
}
```
### show<sup>10+</sup>
show(callback: AsyncCallback\<void>): void
Displays this panel. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
```js
panel.show((err) => {
if (err) {
console.error('Failed to show the panel. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in showing the panel.');
});
```
### show<sup>10+</sup>
show(): Promise\<void>
Displays this panel. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Return value**
| Type | Description |
| ------- | ------------------------------ |
| Promise\<void> | Promise that returns no value. |
**Example**
```js
let promise = panel.show();
promise.then(() => {
console.info('Succeeded in showing the panel.');
}).catch((err) =>{
console.error('Failed to show the panel. err: ' + JSON.stringify(err));
});
```
### hide<sup>10+</sup>
hide(callback: AsyncCallback\<void>): void
Hides this panel. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
```js
panel.hide((err) => {
if (err) {
console.error('Failed to hide the panel. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in hiding the panel.');
});
```
### hide<sup>10+</sup>
hide(): Promise\<void>
Hides this panel. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Return value**
| Type | Description |
| ------- | ------------------------------ |
| Promise\<void> | Promise that returns no value. |
**Example**
```js
let promise = panel.hide();
promise.then(() => {
console.info('Succeeded in hiding the panel.');
}).catch((err) =>{
console.error('Failed to hide the panel. err: ' + JSON.stringify(err));
});
```
### on<sup>10+</sup>
on(type: 'show' | 'hide', callback: () => void): void
Enables listening for a panel visibility event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- |
| type | 'show'\|'hide' | Yes| Listening type.<br>- The value **'show'** indicates the panel display event.<br>- The value **'hide'** indicates the panel hiding event.|
| callback | () => void | Yes | Callback used to return the result.|
**Example**
```js
panel.on('show', () => {
console.info('Panel is showing.');
});
```
### off<sup>10+</sup>
off(type: 'show' | 'hide', callback?: () => void): void
Disables listening for a panel visibility event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- |
| type | 'show'/'hide' | Yes| Listening type.<br>- The value **'show'** indicates the panel display event.<br>- The value **'hide'** indicates the panel hiding event.|
| callback | () => void | No | Callback used to return the result.|
**Example**
```js
panel.off('show');
```
### changeFlag<sup>10+</sup>
changeFlag(flag: PanelFlag): void
Changes the panel state type. This API only works for SOFT_KEYBOARD panels.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- |
| flag | [PanelFlag](#panelflag10) | Yes| State type of the panel to switch to.|
**Example**
```js
let panelFlag = inputMethodEngine.getInputMethodAbility().PanelFlag.FLG_FIXED;
panel.changeFlag(panelFlag);
```
## KeyboardController ## KeyboardController
In the following API examples, you must first use **[on('inputStart')](#oninputstart9)** to obtain a **KeyboardController** instance, and then call the APIs using the obtained instance. In the following API examples, you must first use **[on('inputStart')](#oninputstart9)** to obtain a **KeyboardController** instance, and then call the APIs using the obtained instance.
...@@ -1752,6 +2381,39 @@ Describes the attribute of a key. ...@@ -1752,6 +2381,39 @@ Describes the attribute of a key.
| keyCode | number | Yes | No | Key value.| | keyCode | number | Yes | No | Key value.|
| keyAction | number | Yes | No | Key status.| | keyAction | number | Yes | No | Key status.|
## PanelFlag<sup>10+</sup>
Enumerates the state types of the input method panel.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
| Name | Value| Description |
| ------------ | -- | ------------------ |
| FLG_FIXED | 0 | Fixed state type.|
| FLG_FLOATING | 1 | Floating state type.|
## PanelType<sup>10+</sup>
Enumerates the types of the input method panel.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
| Name | Value| Description |
| ------------ | -- | ------------------ |
| SOFT_KEYBOARD | 0 | Soft keyboard type.|
| STATUS_BAR | 1 | Status bar type.|
## PanelInfo<sup>10+</sup>
**System capability**: SystemCapability.MiscServices.InputMethodFramework
Describes the attributes of the input method panel.
| Name | Type| Readable| Writable| Description |
| --------- | -------- | ---- | ---- | ------------ |
| type | number | Yes | Yes | Type of the panel.|
| flag | number | Yes | Yes | State type of the panel.|
## TextInputClient<sup>(deprecated)</sup> ## TextInputClient<sup>(deprecated)</sup>
> **NOTE** > **NOTE**
...@@ -2250,3 +2912,4 @@ textInputClient.getEditorAttribute().then((editorAttribute) => { ...@@ -2250,3 +2912,4 @@ textInputClient.getEditorAttribute().then((editorAttribute) => {
console.error('Failed to getEditorAttribute: ' + JSON.stringify(err)); console.error('Failed to getEditorAttribute: ' + JSON.stringify(err));
}); });
``` ```
<!--no_check-->
# Input Method Framework Subsystem – Input Method Framework Service Changelog
## @ohos.InputMethodSubtype Change of name, label, and id
Changed the **name**, **label**, and **id** attributes since API version 9.
**Change Impact**
Applications must be adapted to the following changes.
| Name| Before Change| After Change|
| -------- | -------- | -------- |
| label | (1) Value: ID of the input method subtype.| (1) Value: Label of the input method subtype.|
| name | (1) Description: Name of the input method subtype. (2) Value: Label of the input method subtype.| (1) Description: Bundle name of the input method; (2) Value: Bundle name of the input method.|
| id | (1) Value: Bundle name of the input method.| (1) Value: ID of the input method subtype.|
**Adaptation Guide**
Update the code to adapt to the preceding changes.
# Input Method Framework Subsystem – Input Method Framework Service Changelog
## @ohos.InputMethodSubtype Change of name, label, and id
Changed the **name**, **label**, and **id** attributes since API version 9.
**Change Impact**
Applications must be adapted to the following changes.
| Name| Before Change| After Change|
| -------- | -------- | -------- |
| label | (1) Value: ID of the input method subtype.| (1) Value: Label of the input method subtype.|
| name | (1) Description: Name of the input method subtype. (2) Value: Label of the input method subtype.| (1) Description: Bundle name of the input method; (2) Value: Bundle name of the input method.|
| id | (1) Value: Bundle name of the input method.| (1) Value: ID of the input method subtype.|
**Adaptation Guide**
Update the code to adapt to the preceding changes.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册