diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md index c485e0dbe524d76ef59518e0947e7a6b4d7cda91..610cea86fa55077627a85f0492d8c752a5529722 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @@ -37,7 +37,7 @@ import inputMethod from '@ohos.inputMethod'; | labelId10+ | string | 是 | 否 | 非必填。输入法对外显示名称资源号。| | icon9+ | string | 是 | 否 | 非必填。输入法图标数据。| | iconId9+ | number | 是 | 否 | 非必填。输入法图标资源号。 | -| extra10+ | object | 是 | 是 | 非必填。输入法扩展信息。| +| extra9+ | object | 是 | 是 | 输入法扩展信息。
- API version 10起:非必填;
- API version 9:必填。| | packageName(deprecated) | string | 是 | 否 | 输入法包名。必填。
**说明:** 从API version 8开始支持,从API version 9开始废弃,建议使用name替代。 | | methodId(deprecated) | string | 是 | 否 | 输入法唯一标识。必填。
**说明:** 从API version 8开始支持,从API version 9开始废弃,建议使用id替代。 | @@ -212,13 +212,13 @@ getCurrentInputMethod(): InputMethodProperty let currentIme = inputMethod.getCurrentInputMethod(); ``` -## inputMethod.switchCurrentInputMethodSubtype10+ +## inputMethod.switchCurrentInputMethodSubtype9+ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallback\): void 在当前输入法应用内切换子类型。使用callback异步回调。 -**需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**说明:** 从API version 10开始,如果调用者为当前输入法应用,则不需要此权限。 +**需要权限:** ohos.permission.CONNECT_IME_ABILITY
**说明:**
- API version 10起,允许系统应用及当前输入法应用调用;
- API version 9,仅系统应用可用。 **系统能力:** SystemCapability.MiscServices.InputMethodFramework @@ -268,13 +268,13 @@ try { } ``` -## inputMethod.switchCurrentInputMethodSubtype10+ +## inputMethod.switchCurrentInputMethodSubtype9+ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise<boolean> 在当前输入法应用内切换子类型。使用promise异步回调。 -**需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**说明:** 从API version 10开始,如果调用者为当前输入法应用,则不需要此权限。 +**需要权限:** ohos.permission.CONNECT_IME_ABILITY
**说明:**
- API version 10起,允许系统应用及当前输入法应用调用;
- API version 9,仅系统应用可用。 **系统能力:** SystemCapability.MiscServices.InputMethodFramework @@ -634,6 +634,20 @@ let inputMethodSetting = inputMethod.getInputMethodSetting(); | -------- | -------- | -------- | -------- | -------- | | direction | [Direction](#direction10) | 是 | 是 | 进行选中文本动作时光标移动的方向。| +## InputWindowInfo10+ + +输入法软键盘的窗口信息。 + +**系统能力:** SystemCapability.MiscServices.InputMethodFramework + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| name | string | 是 | 是 | 输入法窗口的名称。| +| left | number | 是 | 是 | 输入法窗口左上顶点的横坐标,单位为px。| +| top | number | 是 | 是 | 输入法窗口左上顶点的纵坐标,单位为px。| +| width | number | 是 | 是 | 输入法窗口的宽度,单位为px。| +| height | number | 是 | 是 | 输入法窗口的高度,单位为px。| + ## InputMethodController 下列API示例中都需使用[getController](#inputmethodgetcontroller9)获取到InputMethodController实例,再通过此实例调用对应方法。 @@ -2096,6 +2110,54 @@ off(type: 'imeChange', callback?: (inputMethodProperty: InputMethodProperty, inp inputMethodSetting.off('imeChange'); ``` +### on('imeShow'|'imeHide')10+ + +on(type: 'imeShow'|'imeHide', callback: (info: Array\) => void): void + +订阅输入法软键盘显示或隐藏事件。使用callback异步回调。 + +**系统接口**:此接口为系统接口。 + +**系统能力:** SystemCapability.MiscServices.InputMethodFramework + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---- | ---- | ---- | +| type | string | 是 | 设置监听类型。
- type为`imeShow`时表示订阅输入法软键盘显示事件。
- type为`imeHide`时表示订阅输入法软键盘隐藏事件。 | +| callback | (info: Array\) => void | 是 | 回调函数,返回输入法软键盘信息。 | + +**示例:** + +```js +inputMethodSetting.on('imeShow', (info) => { + console.info('Succeeded in subscribing imeShow event.'); +}); +``` + +### off('imeShow'|'imeHide')10+ + +off(type: 'imeShow'|'imeHide', callback?: (info: Array\) => void): void + +取消订阅输入法软键盘显示或隐藏事件。 + +**系统接口**:此接口为系统接口。 + +**系统能力:** SystemCapability.MiscServices.InputMethodFramework + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---- | ---- | ------ | +| type | string | 是 | 设置监听类型。
- type为`imeShow`时表示取消订阅输入法软键盘显示事件。
- type为`imeHide`时表示取消订阅输入法软键盘隐藏事件。 | +| callback | (info: Array\) => void | 否 | 取消订阅的回调函数。当该参数不填写时,取消订阅type对应的所有回调事件。 | + +**示例:** + +```js +inputMethodSetting.off('imeShow'); +``` + ### listInputMethodSubtype9+ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: AsyncCallback<Array<InputMethodSubtype>>): void