Generally, local images or online images downloaded from the network need to be displayed on a widget. To obtain local and online images, use the FormExtensionAbility. The following exemplifies how to show local and online images on a widget.
1. Internet access is required for downloading online images. Therefore, you need to apply for the **ohos.permission.INTERNET** permission. For details, see[Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md).
1. Internet access is required for downloading online images. Therefore, you need to apply for the **ohos.permission.INTERNET** permission. For details, see[Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md).
2. Update local files in the **onAddForm** lifecycle callback of the EntryFormAbility.
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The **InputMethodCommon** module provides the common attributes defined by the input method framework.
| 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.|
| 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.|
| 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. Optional.<br>**NOTE**<br>This parameter is optional since API version 10.|
| name<sup>9+</sup> | string | Yes| No| Mandatory. Internal name of the input method.|
| id<sup>9+</sup> | string | Yes| No| Mandatory. Unique ID of the input method.|
| label<sup>9+</sup> | string | Yes| No| Optional. External name of the input method.|
| labelId<sup>10+</sup> | string | Yes| No| Optional. External ID of the input method.|
| icon<sup>9+</sup> | string | Yes| No| Optional. Icon of the input method.|
| iconId<sup>9+</sup> | number | Yes| No| Optional. Icon ID of the input method.|
| extra<sup>9+</sup> | object | Yes| Yes| Extra information about the input method.<br>- API version 10 and later: optional<br>- API version 9: mandatory|
| 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**.|
...
...
@@ -61,7 +61,7 @@ For details about the error codes, see [Input Method Framework Error Codes](../e
| Error Code ID| Error Message |
| -------- | ------------------------------ |
| 12800006 | Input method controller error. |
| 12800006 | input method controller error. |
**Example**
...
...
@@ -89,7 +89,7 @@ For details about the error codes, see [Input Method Framework Error Codes](../e
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) <br>**NOTE**<br>Since API version 10, this permission is not required if the caller is the current input method.
**Required permissions**: ohos.permission.CONNECT_IME_ABILITY<br>**NOTE**<br>- API version 10 and later: This API can be called by system applications and the current input method application.<br>- API version 9: This API can be called by system applications only.
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) <br>**NOTE**<br>Since API version 10, this permission is not required if the caller is the current input method.
**Required permissions**: ohos.permission.CONNECT_IME_ABILITY<br>**NOTE**<br>- API version 10 and later: This API can be called by system applications and the current input method application.<br>- API version 9: This API can be called by system applications only.
|inputMethodProperty | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.|
|inputMethodSubtype | [InputMethodSubtype](./js-apis-inputmethod-subtype.md)| Yes| Input method subtype to switch to.|
| callback | AsyncCallback<boolean> | 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**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
Obtains an **[InputMethodController](#inputmethodcontroller)** instance.
> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [getController()](#inputmethodgetcontroller9) instead.
Obtains an **[InputMethodSetting](#inputmethodsetting8)** instance.
> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [getSetting()](#inputmethodgetsetting9) instead.
| textInputType<sup>10+</sup> | [TextInputType](#textinputtype10) | Yes| Yes| Enumerates the text input types.|
| enterKeyType<sup>10+</sup> | [EnterKeyType](#enterkeytype10) | Yes| Yes| Function type represented by the Enter key.|
## TextConfig<sup>10+</sup>
Describes the configuration of the editor component. When the editor component requests to bind the input method, this parameter is transferred to save the configuration of the editor component to the input method framework.
| name | string | Yes| Yes| Name of the input method keyboard window.|
| left | number | Yes| Yes| Horizontal coordinate of the upper left corner of the input method keyboard window, in px.|
| top | number | Yes| Yes| Vertical coordinate of the upper left corner of the input method keyboard window, in px.|
| width | number | Yes| Yes| Width of the input method keyboard window, in px.|
| height | number | Yes| Yes| Height of the input method keyboard window, in px.|
## InputMethodController
In the following API examples, you must first use [getController](#inputmethodgetcontroller9) to obtain an **InputMethodController** instance, and then call the APIs using the obtained instance.
| showKeyboard | boolean | Yes| Whether to start the input method keyboard after the self-drawing component is attached to the input method.|
| textConfig | [TextConfig](#textconfig10) | Yes| Configuration of the editor component.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
Exits the text editing mode. This API uses an asynchronous callback to return the result.
The editor component can call this API to exit the text editing mode. If the soft keyboard is displayed when this API is called, it will be hidden.
Calling this API does not detach the editor component from the input method. The editor component can call [showTextInput](#showtextinput10) again to reenter the text editing mode.
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
| 12800008 | input method manager service error. |
| 12800009 | input method client is detached. |
**Example**
```js
inputMethodController.hideTextInput((err)=>{
if(err){
console.error(`Failed to hideTextInput: ${JSON.stringify(err)}`);
return;
}
console.log('Succeeded in hiding text input.');
});
```
### hideTextInput<sup>10+</sup>
hideTextInput(): Promise<void>
Exits the text editing mode. This API uses a promise to return the result.
The editor component can call this API to exit the text editing mode. If the soft keyboard is displayed when this API is called, it will be hidden.
Calling this API does not detach the editor component from the input method. The editor component can call [showTextInput](#showtextinput10) again to reenter the text editing mode.
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
Sets the window to be avoided by the input method. This API uses an asynchronous callback to return the result.
After the window ID of the application bound to the input method is passed in the API, the input method window will not cover the window holding the application. This API is reserved. Currently, the window ID cannot be obtained.
| windowId | number | Yes| ID of the window to be avoided.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
Sets the window to be avoided by the input method. This API uses a promise to return the result.
After the window ID of the application bound to the input method is passed in the API, the input method window will not cover the window holding the application. This API is reserved. Currently, the window ID cannot be obtained.
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
Updates the information of selected text in this edit box, to notify the input method when the selected text content or text range changes. This API uses an asynchronous callback to return the result.
| start | number | Yes| Start position of the selected text.|
| end | number | Yes| End position of the selected text.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
Updates the information of selected text in this edit box, to notify the input method when the selected text content or text range changes. This API uses a promise to return the result.
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
| callback | AsyncCallback<boolean> | 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**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
| Promise<boolean> | Promise used to return the result. The value **true** means that the ending is successful, and **false** means the opposite.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
Ends this input session. This API uses an asynchronous callback to return the result.
This API must be used with the editor component (for example, a text box). It can be called only when the editor component is focused.
> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [stopInputSession()](#stopinputsession9) instead.
| callback | AsyncCallback<boolean> | 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.|
**Example**
```js
inputMethodController.stopInput((err,result)=>{
if(err){
console.error(`Failed to stopInput: ${JSON.stringify(err)}`);
return;
}
if(result){
console.log('Succeeded in stopping input.');
}else{
console.error('Failed to stopInput.');
}
});
```
### stopInput<sup>(deprecated)</sup>
stopInput(): Promise<boolean>
Ends this input session. This API uses a promise to return the result.
This API must be used with the editor component (for example, a text box). It can be called only when the editor component is focused.
> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [stopInputSession()](#stopinputsession9) instead.
| Promise<boolean> | Promise used to return the result. The value **true** means that the hiding is successful, and **false** means the opposite.|
|inputMethodProperty | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.|
|inputMethodSubtype | [InputMethodSubtype](./js-apis-inputmethod-subtype.md)| Yes| Input method subtype to switch to.|
| callback | AsyncCallback<boolean> | 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.|
| type | string | Yes | Listening type.<br>The value **'insertText'** indicates the text insertion event.|
| callback | (text: string) => void | Yes | Callback used to return the text to be inserted.<br>Your application needs to operate the content in the edit box based on the text content returned in the callback.|
**Error codes**
...
...
@@ -385,53 +1658,54 @@ For details about the error codes, see [Input Method Framework Error Codes](../e
Enables listening for the delete-to-the-left or delete-to-the-right event of the input method. This API uses an asynchronous callback to return the result.
| type | string | Yes | Listening type.<br>- The value **'deleteLeft'** indicates the delete-to-the-left event.<br>- The value **'deleteRight'** indicates the delete-to-the-right event.|
| callback | (length: number) => void | Yes | Callback used to return the length of the text to be deleted to the left or to the right.<br>Your application needs to operate the content in the edit box based on the length returned in the callback.|
**Error codes**
...
...
@@ -439,94 +1713,63 @@ For details about the error codes, see [Input Method Framework Error Codes](../e
| type | string | Yes | Listening type.<br>- The value **'deleteLeft'** indicates the delete-to-the-left event.<br>- The value **'deleteRight'** indicates the delete-to-the-right event.|
In the following API examples, you must first use [getController](#inputmethodgetcontroller9) to obtain an **InputMethodController** instance, and then call the APIs using the obtained instance.
Ends this input session. The invoking of this API takes effect only after the input session is enabled by clicking the text box. This API uses an asynchronous callback to return the result.
Enables listening for the keyboard status event of the input method. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback<boolean> | 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.|
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ---- |
| type | string | Yes | Listening type.<br>The value **'sendKeyboardStatus'** indicates the keyboard status event.|
| callback | (keyBoardStatus: [KeyboardStatus](#keyboardstatus10)) => void | Yes | Callback used to return the keyboard status.<br>Your application needs to perform operations based on the keyboard state returned in the callback.|
**Error codes**
...
...
@@ -534,85 +1777,54 @@ For details about the error codes, see [Input Method Framework Error Codes](../e
console.log(`Succeeded in subscribing sendKeyboardStatus, keyBoardStatus: ${keyBoardStatus}`);
});
}catch(err){
console.error(`Failed to subscribe sendKeyboardStatus: ${JSON.stringify(err)}`);
}
```
### stopInputSession<sup>9+</sup>
### off('sendKeyboardStatus')<sup>10+</sup>
stopInputSession(): Promise<boolean>
off(type: 'sendKeyboardStatus'): void
Ends this input session. The invoking of this API takes effect only after the input session is enabled by clicking the text box. This API uses a promise to return the result.
Disables listening for the keyboard status event of the input method.
| Promise<boolean> | Promise used to return the result. The value **true** means that the ending is successful, and **false** means the opposite.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
Shows this soft keyboard. This API must be used with the input text box and works only when the input text box is activated. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ----- |
| type | string | Yes | Listening type.<br>The value **'sendFunctionKey'** indicates the function key sending event.|
| callback | (functionKey: [FunctionKey](#functionkey10)) => void | Yes | Callback used to return the function key information sent by the input method.<br>Your application needs to perform operations based on the function key information returned in the callback.|
**Error codes**
...
...
@@ -620,214 +1832,170 @@ For details about the error codes, see [Input Method Framework Error Codes](../e
console.log(`Succeeded in subscribing sendFunctionKey, functionKey.enterKeyType: ${functionKey.enterKeyType}`);
});
}catch(err){
console.error(`Failed to subscribe sendFunctionKey: ${JSON.stringify(err)}`);
}
```
### showSoftKeyboard<sup>9+</sup>
showSoftKeyboard(): Promise<void>
### off('sendFunctionKey')<sup>10+</sup>
Shows this soft keyboard. This API must be used with the input text box and works only when the input text box is activated. This API uses a promise to return the result.
off(type: 'sendFunctionKey'): void
**Required permissions**: ohos.permission.CONNECT_IME_ABILITY (available only to system applications)
Disables listening for the function key sending event of the input method.
Hides this soft keyboard. This API must be used with the input text box and works only when the input text box is activated. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
| Name | Type| Mandatory| Description |
| -------- | ------ | ---- | ------ |
| type | string | Yes | Listening type.<br>The value **'moveCursor'** indicates the cursor movement event.|
| callback | callback: (direction: [Direction<sup>10+</sup>](#direction10)) => void | Yes | Callback used to return the cursor movement direction.<br>Your application needs to change the cursor position based on the cursor movement direction returned in the callback.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
console.log(`Succeeded in subscribing moveCursor, direction: ${direction}`);
});
}catch(err){
console.error(`Failed to subscribe moveCursor: ${JSON.stringify(err)}`);
}
```
### hideSoftKeyboard<sup>9+</sup>
hideSoftKeyboard(): Promise<void>
### off('moveCursor')<sup>10+</sup>
Hides this soft keyboard. This API must be used with the input text box and works only when the input text box is activated. This API uses a promise to return the result.
off(type: 'moveCursor'): void
**Required permissions**: ohos.permission.CONNECT_IME_ABILITY (available only to system applications)
Disables listening for the cursor movement event of the input method.
Ends this input session. The invoking of this API takes effect only after the input session is enabled by clicking the text box. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback<boolean> | 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.|
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | -------- |
| type | string | Yes | Listening type.<br>The value **'handleExtendAction'** indicates the extended action handling event.|
| callback | callback: (action: [ExtendAction](#extendaction10)) => void | Yes | Callback used to return the extended action type.<br>Your application needs to perform operations based on the extended action type returned in the callback.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
console.log(`Succeeded in subscribing handleExtendAction, action: ${action}`);
});
}catch(err){
console.error(`Failed to subscribe handleExtendAction: ${JSON.stringify(err)}`);
}
```
### stopInput<sup>(deprecated)</sup>
stopInput(): Promise<boolean>
### off('handleExtendAction')<sup>10+</sup>
Ends this input session. The invoking of this API takes effect only after the input session is enabled by clicking the text box. This API uses a promise to return the result.
off(type: 'handleExtendAction'): void
> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [stopInputSession()](#stopinputsession9).
Disables listening for the extended action handling event of the input method.
| Promise<boolean> | Promise used to return the result. The value **true** means that the hiding is successful, and **false** means the opposite.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| type | string | Yes | Listening type.<br>The value **'handleExtendAction'** indicates the extended action handling event.|
| type | string | Yes | Listening type.<br>The value **selectByRange** indicates the selection-by-range event.|
| callback | Callback<[Range](./js-apis-inputmethod-InputMethodCommon.md#range)> | 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.|
| Name | Type | Mandatory| Description |
| -------- | ---- | ---- | ------- |
| type | string | Yes | Listening type.<br>The value **'selectByRange'** indicates the select-by-range event.|
| callback | Callback<[Range](#range10)> | 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.|
| type | string | Yes | Listening type.<br>The value **selectByMovement** indicates the select-by-cursor-movement event.|
| callback | Callback<[Movement](./js-apis-inputmethod-InputMethodCommon.md#movement)> | 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.|
| Name | Type | Mandatory| Description |
| -------- | ----- | ---- | ------ |
| type | string | Yes | Listening type.<br>The value **'selectByMovement'** indicates the select-by-cursor-movement event.|
| callback | Callback<[Movement](#movement10)> | 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.|
| type | string | Yes| Listening type.<br>- The value **'imeShow'** indicates the soft keyboard display event.<br>- The value **'imeHide'** indicates the soft keyboard hiding event.|
| callback | (info: Array\<InputWindowInfo>) => void | Yes| Callback used to return the information about the soft keyboard of the input method.|
**Example**
```js
inputMethodSetting.on('imeShow',(info)=>{
console.info('Succeeded in subscribing imeShow event.');
| type | string | Yes| Listening type.<br>- The value **'imeShow'** indicates the soft keyboard display event.<br>- The value **'imeHide'** indicates the soft keyboard hiding event.|
| callback | (info: Array\<InputWindowInfo>) => void | No| Callback used for disable listening. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
| inputMethodProperty | InputMethodProperty| Yes| Input method to which the subtypes belong.|
| inputMethodProperty | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to which the subtypes belong.|
| callback | AsyncCallback<Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md)>> | Yes| Callback used to return all subtypes of the specified input method.|
**Error codes**
...
...
@@ -963,29 +2179,26 @@ For details about the error codes, see [Input Method Framework Error Codes](../e
Obtains a list of activated or deactivated input methods. In the current version, an activated input method is the input method in use, and a deactivated one is any of the installed input methods except the one in use. This API uses an asynchronous callback to return the result.
Obtains a list of activated or deactivated input methods. This API uses an asynchronous callback to return the result.
In the current version, an activated input method is the input method in use, and a deactivated one is any of the installed input methods except the one in use.
Obtains a list of activated or deactivated input methods. In the current version, an activated input method is the input method in use, and a deactivated one is any of the installed input methods except the one in use. This API uses a promise to return the result.
Obtains a list of activated or deactivated input methods. This API uses a promise to return the result.
In the current version, an activated input method is the input method in use, and a deactivated one is any of the installed input methods except the one in use.
console.info('Succeeded in listing inputMethod.');
console.log('Succeeded in listing inputMethod.');
}).catch((err)=>{
console.error('Failed to listInputMethod: '+JSON.stringify(err));
console.error(`Failed to listInputMethod: ${JSON.stringify(err)}`);
})
```
...
...
@@ -1334,7 +2548,7 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [showOptionalInputMethods()](#showoptionalinputmethods9).
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [showOptionalInputMethods()](#showoptionalinputmethods9) instead.
console.error('Failed to displayOptionalInputMethod: '+JSON.stringify(err));
return;
}
console.info('Succeeded in displaying optionalInputMethod.');
if(err){
console.error(`Failed to displayOptionalInputMethod: ${JSON.stringify(err)}`);
return;
}
console.log('Succeeded in displaying optionalInputMethod.');
});
```
...
...
@@ -1364,7 +2578,7 @@ Displays a dialog box for selecting an input method. This API uses a promise to
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [showOptionalInputMethods()](#showoptionalinputmethods9-1).
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [showOptionalInputMethods()](#showoptionalinputmethods9-1) instead.
@@ -56,7 +56,9 @@ Provides the constant values of function keys, edit boxes, and the cursor.
getInputMethodAbility(): InputMethodAbility
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.
Obtains an [InputMethodAbility](#inputmethodability) instance for the input method.
This API can be called only by an 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.
@@ -96,11 +98,11 @@ let KeyboardDelegate = inputMethodEngine.getKeyboardDelegate();
getInputMethodEngine(): InputMethodEngine
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.
Obtains an [InputMethodEngine](#inputmethodengine) instance for the input method. The input method can use the obtained instance to subscribe to a soft keyboard display/hide request event.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getInputMethodAbility()](#inputmethodenginegetinputmethodability9).
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getInputMethodAbility()](#inputmethodenginegetinputmethodability9) instead.
@@ -124,7 +126,7 @@ Obtains a [KeyboardDelegate](#keyboarddelegate) instance for the input method. T
> **NOTE**
>
>This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getKeyboardDelegate()](#inputmethodenginegetkeyboarddelegate9).
>This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getKeyboardDelegate()](#inputmethodenginegetkeyboarddelegate9) instead.
| type | string | Yes | Listening type.<br>The value **'setSubtype'** indicates the input method subtype setting event.|
| Name | Type | Mandatory| Description |
| ------- | ----- | ---- | ---- |
| type | string | Yes | Listening type.<br>The value **'setSubtype'** indicates the input method subtype setting event.|
| callback | (inputMethodSubtype: [InputMethodSubtype](js-apis-inputmethod-subtype.md)) => void | No | Callback used to return the input method subtype. |
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.
Creates an input method panel. This API uses an asynchronous callback to return the result.
This API can be called only by an input method. Only one SOFT_KEYBOARD panel and one STATUS_BAR panel can be created for a single input method application.
| ctx | [BaseContext](./js-apis-inner-application-baseContext.md) | Yes | Context of the current input method.|
| 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.|
| callback | AsyncCallback\<[Panel](#panel10)> | Yes | Callback used to return the result. If the operation is successful, the created input method panel is returned. |
...
...
@@ -504,19 +508,19 @@ Creates an input method panel. This API can be called only by input method appli
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.
Creates an input method panel. This API uses a promise to return the result.
This API can be called only by an input method. Only one SOFT_KEYBOARD panel and one STATUS_BAR panel can be created for a single input method application.
| type | string | Yes | Listening type.<br>The value **'cursorContextChange'** indicates the cursor change event.|
| Name | Type | Mandatory | Description |
| -------- | ---- | ---- | ----- |
| type | string | Yes | Listening type.<br>The value **'cursorContextChange'** indicates the cursor change event.|
| callback | (x: number, y: number, height: number) => void | Yes | Callback used to return the cursor information.<br>- **x**: x coordinate of the top of the cursor.<br>- **y**: x coordinate of the bottom of the cursor.<br>- **height**: height of the cursor.|
| type | string | Yes | Listening type.<br>The value **'cursorContextChange'** indicates the cursor change event.|
| Name | Type | Mandatory | Description |
| -------- | ---- | ---- | ------ |
| type | string | Yes | Listening type.<br>The value **'cursorContextChange'** indicates the cursor change event.|
| callback | (x: number, y:number, height:number) => void | No | Callback used to return the cursor information.<br>- **x**: x coordinate of the top of the cursor.<br>- **y**: x coordinate of the bottom of the cursor.<br>- **height**: height of the cursor.<br>|
...
...
@@ -765,7 +771,7 @@ Cancels listening for cursor context changes. This API uses an asynchronous call
| type | string | Yes | Listening type.<br>The value **'selectionChange'** indicates the text selection change event.|
| Name | Type | Mandatory| Description |
| -------- | ----- | ---- | ---- |
| type | string | Yes | Listening type.<br>The value **'selectionChange'** indicates the text selection change event.|
| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | Yes | Callback used to return the text selection information.<br>- **oldBegin**: start of the selected text before the change.<br>- **oldEnd**: end of the selected text before the change.<br>- **newBegin**: start of the selected text after the change.<br>- **newEnd**: end of the selected text after the change.|
| type | string | Yes | Listening type.<br>The value **'selectionChange'** indicates the text selection change event.|
| Name | Type | Mandatory| Description |
| -------- | ------- | ---- | ------- |
| type | string | Yes | Listening type.<br>The value **'selectionChange'** indicates the text selection change event.|
| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | No | Callback used to return the text selection information.<br>- **oldBegin**: start of the selected text before the change.<br>- **oldEnd**: end of the selected text before the change.<br>- **newBegin**: start of the selected text after the change.<br>- **newEnd**: end of the selected text after the change.<br>|
**Example**
...
...
@@ -831,13 +837,13 @@ Enables listening for the text change event. This API uses an asynchronous callb
| 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.|
| storage | [LocalStorage](../../quick-start/arkts-localstorage.md) | 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.|
| 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.|
| storage | [LocalStorage](../../quick-start/arkts-localstorage.md) | Yes | Storage unit that provides storage for mutable and immutable state variables in the application.|
| width | number | Yes | Target width of the panel, in pixels.|
| height | number | Yes | Target height of the panel, in pixels.|
| width | number | Yes | Target width of the panel, in px.|
| height | number | Yes | Target height of the panel, in px.|
| 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**
...
...
@@ -1029,13 +1036,13 @@ The panel width cannot exceed the screen width, and the panel height cannot be h
try{
panel.resize(500,1000,(err)=>{
if(err){
console.error('Failed to change the panel size. Cause:'+JSON.stringify(err));
console.error(`Failed to resize panel: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in changing the panel size.');
console.log('Succeeded in changing the panel size.');
});
}catch(exception){
console.error('Failed to change the panel size. Cause:'+JSON.stringify(exception));
}catch(err){
console.error(`Failed to resize panel: ${JSON.stringify(err)}`);
| 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.|
| y | number | Yes | Distance to move along the y-axis, in px. 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**
...
...
@@ -1099,13 +1108,13 @@ This API does not work on panels in the FLG_FIXED state.
try{
panel.moveTo(300,300,(err)=>{
if(err){
console.error('Failed to move the panel. err:'+JSON.stringify(err));
console.error(`Failed to move panel: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in moving the panel.');
console.log('Succeeded in moving the panel.');
});
}catch(exception){
console.error('Failed to move the panel. err:'+JSON.stringify(exception));
}catch(err){
console.error(`Failed to move panel: ${JSON.stringify(err)}`);
}
```
...
...
@@ -1113,7 +1122,8 @@ try {
moveTo(x: number, y: number): Promise\<void>
Moves this panel to the specified position. This API uses a promise to return the result.
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.
| type | 'show'/'hide' | Yes| Listening type.<br>- The value **'show'** indicates the panel display event.<br>- The value **'hide'** indicates the panel hiding event.|
| 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**
...
...
@@ -1309,7 +1319,7 @@ Changes the panel state type. This API only works for SOFT_KEYBOARD panels.
| direction | [Direction](#direction10) | Yes| Yes| Direction in which the cursor moves when the text is selected.|
## InputClient<sup>9+</sup>
In the following API examples, you must first use **[on('inputStart')](#oninputstart9)** to obtain an **InputClient** instance, and then call the APIs using the obtained instance.
...
...
@@ -1457,7 +1514,7 @@ Sends the function key. This API uses an asynchronous callback to return the res
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| action | number | Yes| Action of the function key.<br>**0**: invalid key.<br>**1**: confirm key (Enter key).|
| action | number | Yes| Action of the function key.<br>- **0**: invalid key.<br>- **1**: confirm key (Enter key).|
| callback | AsyncCallback<boolean> | 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**
...
...
@@ -1473,19 +1530,19 @@ For details about the error codes, see [Input Method Framework Error Codes](../e
| range | [Range](./js-apis-inputmethod-InputMethodCommon.md#range) | Yes | Range of the selected text. |
| range | [Range](#range10) | Yes | Range of the selected text. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the selection event is sent, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes**
...
...
@@ -2152,15 +2209,15 @@ For details about the error codes, see [Input Method Framework Error Codes](../e
| movement | [Movement](./js-apis-inputmethod-InputMethodCommon.md#movement) | Yes | Direction in which the cursor moves when the text is selected. |
| callback | AsyncCallback<void>| Yes | Callback used to return the result. If the selection event is sent, **err** is **undefined**; otherwise, **err** is an error object.|
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------ |
| movement | [Movement](#movement10) | Yes | Direction in which the cursor moves when the text is selected. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the selection event is sent, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes**
...
...
@@ -2235,15 +2292,15 @@ For details about the error codes, see [Input Method Framework Error Codes](../e
Sends an extended edit action. This API uses an asynchronous callback to return the result.
The input method calls this API to send an extended edit action to an editor component (for example, a text box), which in turn listens for the corresponding event [on(handleExtendAction)](./js-apis-inputmethod.md#onhandleextendaction10) for further processing.
| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
Sends an extended edit action. This API uses a promise to return the result.
The input method calls this API to send an extended edit action to an editor component (for example, a text box), which in turn listens for the corresponding event [on(handleExtendAction)](./js-apis-inputmethod.md#onhandleextendaction10) for further processing.
console.log('Succeeded in sending extend action.');
}).catch((err)=>{
console.error(`Failed to sendExtendAction: ${JSON.stringify(err)}`);
});
}catch(err){
console.error(`Failed to sendExtendAction: ${JSON.stringify(err)}`);
}
```
## EditorAttribute
Attribute of the edit box.
...
...
@@ -2418,7 +2561,7 @@ Describes the attributes of the input method panel.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [InputClient](#inputclient9).
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [InputClient](#inputclient9) instead.
In the following API examples, you must first use **[on('inputStart')](#oninputstart)** to obtain a **TextInputClient** instance, and then call the APIs using the obtained instance.
...
...
@@ -2430,7 +2573,7 @@ Obtains the specific-length text before the cursor. This API uses an asynchronou
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getForward](#getforward9).
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getForward](#getforward9) instead.
| callback | AsyncCallback<boolean> | 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.|
| action | number | Yes| Action of the function key.<br>**0**: invalid key.<br>**1**: confirm key (Enter key).|
| action | number | Yes| Action of the function key.<br>- **0**: invalid key.<br>- **1**: confirm key (Enter key).|
| callback | AsyncCallback<boolean> | 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.|
console.error('Failed to insertText: '+JSON.stringify(err));
console.error(`Failed to insertText: ${JSON.stringify(err)}`);
});
```
...
...
@@ -2861,26 +3004,26 @@ Obtains the attribute of the edit box. This API uses an asynchronous callback to
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getEditorAttribute](#geteditorattribute9).
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getEditorAttribute](#geteditorattribute9) instead.
| callback | AsyncCallback<[EditorAttribute](#editorattribute)> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the attribute of the edit box. Otherwise, **err** is an error object.|
@@ -2892,7 +3035,7 @@ Obtains the attribute of the edit box. This API uses a promise to return the res
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getEditorAttribute](#geteditorattribute9).
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getEditorAttribute](#geteditorattribute9) instead.
@@ -38,7 +38,7 @@ The input method process is suspended.
**Solution**
Check whether the input method process is running properly. For example, click the input text box in an appliccation and check whether the input keyboard is displayed.
Check whether the input method process is running properly. For example, click the input text box in an application and check whether the input keyboard is displayed.
## 12800003 Input Method Client Error
...
...
@@ -58,23 +58,23 @@ The input method is disconnected from the third-party application due to a servi
Bind the input method to the third-party application again: Close the background process of the third-party application, start the application again, and touch an input text box. If the keyboard is displayed properly, the issue is resolved.
## 12800004 Key Event Processing Error
## 12800004 Not an Input Method.
**Error Message**
Key event processing error.
Not an input method extension.
**Description**
This error code is reported when a key event error occurs.
This error code is reported when an API exclusive to input methods is called by an application of another type.
**Possible Causes**
An exception occurs during key event distribution, consumption, or listening.
An API that can be called only by an input method is called by an application of another type.
**Solution**
None
Call the API only in an input method.
## 12800005 Configuration Persistence Error
...
...
@@ -147,3 +147,21 @@ The input method manager service fails to be obtained.
**Solution**
Run the **ps -A|grep inputmethod** command to check for the process ID of the input method service. If the process ID is found, the service is working properly.
## 12800009 Input Method Client Detached
**Error Message**
Input method client is detached.
**Description**
This error code is reported when the current application is not attached to an input method.
**Possible Causes**
The current application calls **showTextInput** or **hideTextInput** when not attached to an input method.