“9c41f5cdbf11d77b1cb54d3e81ca66b11bd0a311”上不存在“src/client/git@gitcode.net:taosdata/tdengine.git”
提交 a2ad219b 编写于 作者: H Hollokin

输入法框架资料需求:包括窗口创建,自绘控件,三方应用监听输入法窗口显示隐藏事件等

Signed-off-by: NHollokin <taoyuxin2@huawei.com>
上级 dea204e3
...@@ -510,23 +510,1307 @@ getInputMethodSetting(): InputMethodSetting ...@@ -510,23 +510,1307 @@ getInputMethodSetting(): InputMethodSetting
let inputMethodSetting = inputMethod.getInputMethodSetting(); let inputMethodSetting = inputMethod.getInputMethodSetting();
``` ```
## TextInputType<sup>10+</sup>
输入法文本输入类型。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
| 名称 | 值 |说明 |
| -------- | -------- |-------- |
| NONE | -1 |NONE。 |
| TEXT | 0 |文本类型。 |
| MULTILINE | |多行类型。 |
| NUMBER | |数字类型。 |
| PHONE | |电话号码类型。 |
| DATETIME | |日期类型。 |
| EMAIL_ADDRESS | |邮箱地址类型。 |
| URL | |链接类型。 |
| VISIBLE_PASSWORD | |密码类型。 |
## EnterKeyType<sup>10+</sup>
输入法Enter键所代表的功能类型。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
| 名称 | 值 |说明 |
| -------- | -------- |-------- |
| UNSPECIFIED | 0 |未指定。 |
| NONE | |NONE。 |
| GO | |前往。 |
| SEARCH | |查找。 |
| SEND | |发送。 |
| NEXT | |下一步。 |
| DONE | |完成。 |
| PREVIOUS | |上一步。 |
## KeyboardStatus<sup>10+</sup>
输入法软键盘状态。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
| 名称 | 值 |说明 |
| -------- | -------- |-------- |
| NONE | 0 |NONE。 |
| HIDE | 1 |隐藏状态。 |
| SHOW | 2 |显示状态。 |
## Direction<sup>10+</sup>
光标移动方向。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
| 名称 | 值 |说明 |
| -------- | -------- |-------- |
| CURSOR_UP | 1 |向上。 |
| CURSOR_DOWN | |向下。 |
| CURSOR_LEFT | |向左。 |
| CURSOR_RIGHT | |向右。 |
## ExtendAction<sup>10+</sup>
对编辑框中文本的扩展编辑操作类型。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
| 名称 | 值 |说明 |
| -------- | -------- |-------- |
| SELECT_ALL | 0 |全选。 |
| CUT | 3 |剪切。 |
| COPY | 4 |复制。 |
| PASTE | 5 |粘贴。 |
## InputWindowInfo<sup>10+</sup>
输入法软键盘的窗口信息。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| name<sup>10+</sup> | string | 是 | 是 | 输入法窗口的名称。|
| left<sup>10+</sup> | string | 是 | 是 | 输入法窗口左上顶点的x坐标。|
| top<sup>10+</sup> | string | 是 | 是 | 输入法窗口左上顶点的y坐标。|
| width<sup>10+</sup> | string | 是 | 是 | 输入法窗口的宽度。|
| height<sup>10+</sup> | string | 是 | 是 | 输入法窗口的高度。|
## FunctionKey<sup>10+</sup>
输入法功能键类型。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| enterKeyType<sup>10+</sup> | [EnterKeyType](#enterkeytype10) | 是 | 是 | 输入法enter键类型。|
## InputAttribute<sup>10+</sup>
编辑框属性,包含文本输入类型,Enter键功能类型。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| textInputType<sup>10+</sup> | [TextInputType](#textinputtype10) | 是 | 是 | 文本输入类型。|
| enterKeyType<sup>10+</sup> | [EnterKeyType](#enterkeytype10) | 是 | 是 | Enter键类型。|
## TextConfig<sup>10+</sup>
编辑控件配置。编辑控件请求绑定输入法框架时传入,将编辑控件相关属性配置到输入法框架内。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| inputAttribute<sup>10+</sup> | [InputAttribute](#inputattribute10) | 是 | 是 | 编辑框属性。|
## CursorInfo<sup>10+</sup>
光标信息。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| left | number | 是 | 是 | 光标的left坐标。|
| top | number | 是 | 是 | 光标的top坐标。|
| width | number | 是 | 是 | 光标的宽度。|
| height | number | 是 | 是 | 光标的高度。|
## Range<sup>10+</sup>
描述选中文本的范围。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| start | number | 是 | 是 | 选中文本的首字符在编辑框的索引值。|
| end | number | 是 | 是 | 选中文本的末字符在编辑框的索引值。|
## Movement<sup>10+</sup>
描述进行选中文本动作时光标移动的方向。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| direction | [Direction](#direction10) | 是 | 是 | 进行选中文本动作时光标移动的方向。|
## InputMethodController ## InputMethodController
下列API示例中都需使用[getController](#inputmethodgetcontroller9)获取到InputMethodController实例,再通过此实例调用对应方法。 下列API示例中都需使用[getController](#inputmethodgetcontroller9)获取到InputMethodController实例,再通过此实例调用对应方法。
### attach<sup>10+</sup>
attach(showKeyboard: boolean, textConfig: TextConfig, callback: AsyncCallback&lt;void&gt;): void
用于自绘控件绑定输入法框架。自绘控件开发者必须先调用此接口完成绑定,才可以使用框架提供的以下功能,使用callback异步回调。
[showTextInput](#showtextinput10)
[hideTextInput](#hidetextinput10)
[setCallingWindow](#setcallingwindow10)
[updateCursor](#updatecursor10)
[changeSelection](#changeselection10)
[updateAttribute](#updateattribute10)
[on('insertText')](#oninserttext10)
[on('deleteLeft' | 'deleteRight')](#ondeleteleft--deleteright10)
[on('sendKeyboardStatus')](#onsendkeyboardstatus10)
[on('sendFunctionKey')](#onsendfunctionkey10)
[on('moveCursor')](#onmovecursor10)
[on('handleExtendAction')](#onhandleextendaction10)
[off('insertText')](#offinserttext10)
[off('deleteLeft' | 'deleteRight')](#offdeleteleft--deleteright10)
[off('sendKeyboardStatus')](#offsendkeyboardstatus10)
[off('sendFunctionKey')](#offsendfunctionkey10)
[off('moveCursor')](#offmovecursor10)
[off('handleExtendAction')](#offhandleextendaction10)
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| showKeyboard | boolean | 是 | 绑定输入法成功后是否拉起输入法键盘。 |
| textConfig | [TextConfig](#textconfig10) | 是 | 编辑控件配置。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当绑定输入法成功后,err为undefined;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```js
try {
let textConfig: inputMethod.TextConfig = {inputAttribute: {textInputType: inputMethodController.TextInputType.TEXT,
enterKeyType: inputMethodController.EnterKeyType.GO}};
inputMethodController.attach(true, textConfig, (err) => {
if (err !== undefined) {
console.error(`Failed to attach: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in attaching the inputMethod.');
});
} catch(error) {
console.error(`Failed to attach: ${JSON.stringify(error)}`);
}
```
### attach<sup>10+</sup>
attach(showKeyboard: boolean, textConfig: TextConfig): Promise&lt;void&gt;
用于自绘控件解绑定输入法框架。自绘控件开发者必须先调用此接口完成绑定,才可以使用框架提供的以下功能,使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| showKeyboard | boolean | 是 | 绑定输入法成功后是否拉起输入法键盘。 |
| textConfig | [TextConfig](#textconfig10) | 是 | 编辑框属性。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```js
try {
let textConfig: inputMethod.TextConfig = {inputAttribute: {textInputType: inputMethodController.TextInputType.TEXT,
enterKeyType: inputMethodController.EnterKeyType.GO}};
inputMethodController.attach(true, textConfig).then(() => {
console.info('Succeeded in attaching inputMethod.');
}).catch((err) => {
console.error(`Failed to attach: ${JSON.stringify(err)}`);
})
} catch(error) {
console.error(`Failed to attach: ${JSON.stringify(error)}`);
}
```
### showTextInput<sup>10+</sup>
showTextInput(callback: AsyncCallback&lt;void&gt;): void
进入文本编辑状态。编辑控件绑定输入法应用成功后可以使用该接口显示输入法应用软键盘。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。若成功进入编辑状态,err为undefined;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```js
inputMethodController.showTextInput((err) => {
if (err !== undefined) {
console.error(`Failed to showTextInput: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in showing the inputMethod.');
});
```
### showTextInput<sup>10+</sup>
showTextInput(): Promise&lt;void&gt;
进入文本编辑状态。编辑控件绑定输入法应用成功后可以使用该接口显示输入法应用软键盘。使用promise异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```js
inputMethodController.showTextInput().then(() => {
console.info('Succeeded in showing inputMethod.');
}).catch((err) => {
console.error(`Failed to showTextInput: ${JSON.stringify(err)}`);
});
```
### hideTextInput<sup>10+</sup>
hideTextInput(callback: AsyncCallback&lt;void&gt;): void
退出文本编辑状态。编辑控件可调用该接口退出编辑状态,若当前软键盘正在显示,则软键盘会被隐藏。调用该接口不解除与输入法框架的绑定,再次直接调用[showTextInput](#showtextinput10)可重新进入编辑状态。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当成功退出编辑状态时,err为undefined;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```js
inputMethodController.hideTextInput((err) => {
if (err !== undefined) {
console.error(`Failed to hideTextInput: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in hiding inputMethod.');
});
```
### hideTextInput<sup>10+</sup>
hideTextInput(): Promise&lt;void&gt;
退出文本编辑状态。编辑控件可调用该接口退出编辑状态,若当前软键盘正在显示,则软键盘会被隐藏。调用该接口不解除与输入法框架的绑定,再次直接调用[showTextInput](#showtextinput10)可重新进入编辑状态。使用promise异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```js
try {
inputMethodController.hideTextInput().then(() => {
console.info('Succeeded in hiding inputMethod.');
}).catch((err) => {
console.error(`Failed to hideTextInput: ${JSON.stringify(err)}`);
})
} catch(err) {
console.error(`Failed to hideTextInput: ${JSON.stringify(err)}`);
}
```
### detach<sup>10+</sup>
detach(callback: AsyncCallback&lt;void&gt;): void
解绑定输入法框架。自绘控件通过该接口可以解绑定输入法,解绑定后以下操作不被允许。使用callback异步回调。
[showTextInput](#showtextinput10)
[hideTextInput](#hidetextinput10)
[setCallingWindow](#setcallingwindow10)
[updateCursor](#updatecursor10)
[changeSelection](#changeselection10)
[updateAttribute](#updateattribute10)
[on('insertText')](#oninserttext10)
[on('deleteLeft' | 'deleteRight')](#ondeleteleft--deleteright10)
[on('sendKeyboardStatus')](#onsendkeyboardstatus10)
[on('sendFunctionKey')](#onsendfunctionkey10)
[on('moveCursor')](#onmovecursor10)
[on('handleExtendAction')](#onhandleextendaction10)
[off('insertText')](#offinserttext10)
[off('deleteLeft' | 'deleteRight')](#offdeleteleft--deleteright10)
[off('sendKeyboardStatus')](#offsendkeyboardstatus10)
[off('sendFunctionKey')](#offsendfunctionkey10)
[off('moveCursor')](#offmovecursor10)
[off('handleExtendAction')](#offhandleextendaction10)
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当解绑定输入法成功时,err为undefined;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```js
inputMethodController.detach((err) => {
if (err !== undefined) {
console.error(`Failed to detach: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in detaching inputMethod.');
});
```
### detach<sup>10+</sup>
detach(): Promise&lt;void&gt;
解绑定输入法框架。自绘控件通过该接口可以解绑定输入法,解绑定后以下操作不被允许。使用promise异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```js
inputMethodController.detach().then(() => {
console.info('Succeeded in detaching inputMethod.');
}).catch((error) => {
console.error(`Failed to detach: ${JSON.stringify(error)}`);
});
```
### setCallingWindow<sup>10+</sup>
setCallingWindow(windowId: number, callback: AsyncCallback&lt;void&gt;): void
避让窗口。将当前绑定到输入法的应用程序的窗口ID通知系统,正确设置后,客户端所在的窗口可以避开输入法窗口。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| windowId | number | 是 | 当前绑定到输入方法的应用程序的窗口ID。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当设置成功时,err为undefined;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```js
try {
let windowId: number = 2000;
inputMethodController.setCallingWindow(windowId, (err) => {
if (err !== undefined) {
console.error(`Failed to setCallingWindow: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in setting callingWindow.');
});
} catch(error) {
console.error(`Failed to setCallingWindow: ${JSON.stringify(error)}`);
}
```
### setCallingWindow<sup>10+</sup>
setCallingWindow(windowId: number): Promise&lt;void&gt;
避让窗口。将当前绑定到输入法的应用程序的窗口ID通知系统,正确设置后,客户端所在的窗口可以避开输入法窗口。使用promise异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| windowId | number | 是 | 当前绑定到输入方法的应用程序的窗口ID。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```js
try {
let windowId: number = 2000;
inputMethodController.setCallingWindow(windowId).then(() => {
console.info('Succeeded in setting callingWindow.');
}).catch((err) => {
console.error(`Failed to setCallingWindow: ${JSON.stringify(err)}`);
})
} catch(error) {
console.error(`Failed to setCallingWindow: ${JSON.stringify(error)}`);
}
```
### updateCursor<sup>10+</sup>
updateCursor(cursorInfo: CursorInfo, callback: AsyncCallback&lt;void&gt;): void
向输入法应用更新当前编辑框内光标信息,要求开发者在编辑控件内光标信息发生改变时调用该接口更新信息。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| cursorInfo | [CursorInfo](#cursorinfo10) | 是 | 光标信息。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当设置成功时,err为undefined;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```js
try {
inputMethodController.updateCursor({left: 0, top: 0, width: 600, height: 800}, (err) => {
if (err !== undefined) {
console.error(`Failed to updateCursor: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in updating cursorInfo.');
});
} catch(error) {
console.error(`Failed to updateCursor: ${JSON.stringify(error)}`);
}
```
### updateCursor<sup>10+</sup>
updateCursor(cursorInfo: CursorInfo): Promise&lt;void&gt;
通知输入法当前应用程序光标已更改。使用promise异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| cursorInfo | [CursorInfo](#cursorinfo10) | 是 | 光标信息。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```js
try {
inputMethodController.updateCursor({left: 0, top: 0, width: 600, height: 800}).then(() => {
console.info('Succeeded in updating cursorInfo.');
}).catch((err) => {
console.error(`Failed to updateCursor: ${JSON.stringify(err)}`);
})
} catch(error) {
console.error(`Failed to updateCursor: ${JSON.stringify(error)}`);
}
```
### changeSelection<sup>10+</sup>
changeSelection(text: string, start: number, end: number, callback: AsyncCallback&lt;void&gt;): void
向输入法应用更新当前编辑框内被选中文本的信息,要求开发者在编辑控件内被选中文本内容或范围发生变化时调用该接口更新信息。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| text | string | 是 | 整个输入文本。 |
| start | number | 是 | 所选文本的起始位置。 |
| end | number | 是 | 所选文本的结束位置。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当隐藏输入法成功时,err为undefined;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```js
try {
inputMethodController.changeSelection('text', 0, 5, (err) => {
if (err !== undefined) {
console.error(`Failed to changeSelection: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in changing selection.');
});
} catch(error) {
console.error(`Failed to changeSelection: ${JSON.stringify(error)}`);
}
```
### changeSelection<sup>10+</sup>
changeSelection(text: string, start: number, end: number): Promise&lt;void&gt;
通知输入法当前应用程序文本的选择范围已更改。使用promise异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| text | string | 是 | 整个输入文本。 |
| start | number | 是 | 所选文本的起始位置。 |
| end | number | 是 | 所选文本的结束位置。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```js
try {
inputMethodController.changeSelection('test', 0, 5).then(() => {
console.info('Succeeded in changing selection.');
}).catch((err) => {
console.error(`Failed to changeSelection: ${JSON.stringify(err)}`);
})
} catch(error) {
console.error(`Failed to changeSelection: ${JSON.stringify(error)}`);
}
```
### updateAttribute<sup>10+</sup>
updateAttribute(attribute: InputAttribute, callback: AsyncCallback&lt;void&gt;): void
更新编辑框属性。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| attribute | [InputAttribute](#inputattribute10) | 是 | InputAttribute对象,包含的额外信息。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当隐藏输入法成功时,err为undefined;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```js
try {
inputMethodController.updateAttribute({textInputType: inputMethod.TextInputType.TEXT,
enterKeyType: inputMethod.EnterKeyType.GO}, (err) => {
if (err !== undefined) {
console.error(`Failed to updateAttribute: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in updating attribute.');
});
} catch(error) {
console.error(`Failed to updateAttribute: ${JSON.stringify(error)}`);
}
```
### updateAttribute<sup>10+</sup>
updateAttribute(attribute: InputAttribute): Promise&lt;void&gt;
更新输入文本的InputAttribute信息。使用promise异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| attribute | [InputAttribute](#inputattribute10) | 是 | InputAttribute对象,包含的额外信息。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```js
try {
inputMethodController.updateAttribute({textInputType: inputMethod.TextInputType.TEXT,
enterKeyType: inputMethod.EnterKeyType.GO}).then(() => {
console.info('Succeeded in updating attribute.');
}).catch((err) => {
console.error(`Failed to updateAttribute: ${JSON.stringify(err)}`);
})
} catch(error) {
console.error(`Failed to updateAttribute: ${JSON.stringify(error)}`);
}
```
### stopInputSession<sup>9+</sup>
stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void
结束输入会话。通过点击输入框实现输入会话的开启之后该接口的调用才可生效。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当结束输入会话成功时,err为undefined,data为true;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```js
try {
inputMethodController.stopInputSession((error, result) => {
if (error !== undefined) {
console.error('Failed to stopInputSession: ' + JSON.stringify(error));
return;
}
if (result) {
console.info('Succeeded in stopping inputSession.');
} else {
console.error('Failed to stopInputSession.');
}
});
} catch(error) {
console.error('Failed to stopInputSession: ' + JSON.stringify(error));
}
```
### stopInputSession<sup>9+</sup>
stopInputSession(): Promise&lt;boolean&gt;
结束输入会话。通过点击输入框实现输入会话的开启之后此接口才可生效。使用promise异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise对象。返回true表示结束输入会话成功;返回false表示结束输入会话失败。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```js
try {
inputMethodController.stopInputSession().then((result) => {
if (result) {
console.info('Succeeded in stopping inputSession.');
} else {
console.error('Failed to stopInputSession.');
}
}).catch((err) => {
console.error('Failed to stopInputSession: ' + JSON.stringify(err));
})
} catch(err) {
console.error('Failed to stopInputSession: ' + JSON.stringify(err));
}
```
### showSoftKeyboard<sup>9+</sup>
showSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
显示软键盘。需要与输入框绑定使用。当点击输入框后,才可通过该接口的调用显示出当前输入法的软键盘。使用callback异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当软键盘显示成功。err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```js
inputMethodController.showSoftKeyboard((err) => {
if (err === undefined) {
console.info('Succeeded in showing softKeyboard.');
} else {
console.error('Failed to showSoftKeyboard: ' + JSON.stringify(err));
}
})
```
### showSoftKeyboard<sup>9+</sup>
showSoftKeyboard(): Promise&lt;void&gt;
显示软键盘。需要与输入框绑定使用。当点击输入框后,才可通过该接口的调用显示出当前输入法的软键盘。使用Promise异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```js
inputMethodController.showSoftKeyboard().then(() => {
console.log('Succeeded in showing softKeyboard.');
}).catch((err) => {
console.error('Failed to showSoftKeyboard: ' + JSON.stringify(err));
});
```
### hideSoftKeyboard<sup>9+</sup>
hideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
隐藏软键盘。需要与输入框绑定使用。点击输入框后,才可以使用该接口的调用隐藏软键盘。使用callback异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当软键盘隐藏成功。err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```js
inputMethodController.hideSoftKeyboard((err) => {
if (err === undefined) {
console.info('Succeeded in hiding softKeyboard.');
} else {
console.error('Failed to hideSoftKeyboard: ' + JSON.stringify(err));
}
})
```
### hideSoftKeyboard<sup>9+</sup>
hideSoftKeyboard(): Promise&lt;void&gt;
隐藏软键盘。需要与输入框绑定使用。点击输入框后,才可以使用该接口的调用隐藏软键盘。使用Promise异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```js
inputMethodController.hideSoftKeyboard().then(() => {
console.log('Succeeded in hiding softKeyboard.');
}).catch((err) => {
console.error('Failed to hideSoftKeyboard: ' + JSON.stringify(err));
});
```
### stopInput<sup>(deprecated)</sup>
stopInput(callback: AsyncCallback&lt;boolean&gt;): void
结束输入会话。通过点击输入框实现输入会话的开启之后该接口的调用才可生效。使用callback异步回调。
> **说明:**
>
> 从API version 6开始支持,从API version 9开始废弃, 建议使用[stopInputSession()](#stopinputsession9)替代。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当输入法隐藏成功,err为undefined,data为true;否则为错误对象。 |
**示例:**
```js
inputMethodController.stopInput((error, result) => {
if (error !== undefined) {
console.error('Failed to stopInput: ' + JSON.stringify(error));
return;
}
if (result) {
console.info('Succeeded in stopping input.');
} else {
console.error('Failed to stopInput.');
}
});
```
### stopInput<sup>(deprecated)</sup>
stopInput(): Promise&lt;boolean&gt;
结束输入会话。通过点击输入框实现输入会话的开启之后该接口的调用才可生效。使用promise异步回调。
> **说明:**
>
> 从API version 6开始支持,从API version 9开始废弃, 建议使用[stopInputSession()](#stopinputsession9)替代。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise对象。返回true表示输入法隐藏成功;返回false表示输入法隐藏失败。 |
**示例:**
```js
inputMethodController.stopInput().then((result) => {
if (result) {
console.info('Succeeded in stopping input.');
} else {
console.error('Failed to stopInput.');
}
}).catch((err) => {
console.error('Failed to stopInput: ' + err);
})
```
### on('insertText')<sup>10+</sup>
on(type: 'insertText', callback: (text: string) => void): void;
订阅输入法应用插入文本事件。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘insertText’时表示订阅输入法应用插入文本事件监听。 |
| callback | (text: string) => void | 是 | 回调函数,返回需要插入的文本内容。<br/>开发者需要在回调函数中根据传入的文本内容操作编辑框中的内容。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800009 | Input method client is detached. |
**示例:**
```js
try {
inputMethodController.on('insertText', (text) => {
console.info(`Succeeded in subscribing insertText: ${text}`);
});
} catch(error) {
console.error(`Failed to subscribe insertText: ${JSON.stringify(error)}`);
}
```
### off('insertText')<sup>10+</sup>
off(type: 'insertText'): void
取消订阅输入法应用插入文本事件。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘insertText’时表示取消订阅输入法应用插入文本事件监听。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800009 | Input method client is detached. |
**示例:**
```js
try {
inputMethodController.off('insertText');
console.info('Succeeded in unsubscribing insertText.');
} catch(error) {
console.error(`Failed to unsubscribe insertText: ${JSON.stringify(error)}`);
}
```
### on('deleteLeft' | 'deleteRight')<sup>10+</sup>
on(type: 'deleteLeft' | 'deleteRight', callback: (length: number) => void): void
订阅输入法应用向左删除或向右删除事件。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘deleteLeft’时表示订阅输入法应用向左删除事件监听。 <br/>-type为‘deleteRight’时表示订阅输入法应用向右删除事件监听。|
| callback | (length: number) => void | 是 | 回调函数,返回需要向左或向右删除的文本的长度。<br/>开发者需要在回调函数中根据传入的删除长度操作编辑框中相应文本。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800009 | Input method client is detached. |
**示例:**
```js
try {
inputMethodController.on('deleteLeft', (length) => {
console.info(`Succeeded in subscribing deleteLeft, length: ${length}`);
});
} catch(error) {
console.error(`Failed to subscribe deleteLeft: ${JSON.stringify(error)}`);
}
try {
inputMethodController.on('deleteRight', (length) => {
console.info(`Succeeded in subscribing deleteRight, length: ${length}`);
});
} catch(error) {
console.error(`Failed to subscribe deleteRight: ${JSON.stringify(error)}`);
}
```
### off('deleteLeft' | 'deleteRight')<sup>10+</sup>
off(type: 'deleteLeft' | 'deleteRight'): void
取消订阅输入法应用向左或向右删除文本事件。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘deleteLeft’时表示取消订阅输入法应用向左删除的事件监听。 <br/>-type为‘deleteRight’时表示取消订阅输入法应用向右删除的事件监听。|
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800009 | Input method client is detached. |
### stopInputSession<sup>9+</sup> **示例:**
stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void ```js
try {
inputMethodController.off('deleteLeft');
console.info('Succeeded in unsubscribing deleteLeft.');
} catch(error) {
console.error(`Failed to unsubscribe deleteLeft: ${JSON.stringify(error)}`);
}
结束输入会话。通过点击输入框实现输入会话的开启之后该接口的调用才可生效。使用callback异步回调。 try {
inputMethodController.off('deleteRight');
console.info('Succeeded in unsubscribing deleteRight.');
} catch(error) {
console.error(`Failed to unsubscribe deleteRight: ${JSON.stringify(error)}`);
}
```
### on('sendKeyboardStatus')<sup>10+</sup>
on(type: 'sendKeyboardStatus', callback: (keyBoardStatus: KeyboardStatus) => void): void
订阅输入法应用发送键盘状态事件。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当结束输入会话成功时,err为undefined,data为true;否则为错误对象。 | | type | string | 是 | 设置监听类型。<br/>-type为‘sendKeyboardStatus’时表示订阅输入法应用发送键盘状态事件监听。 |
| callback | (keyBoardStatus: [KeyboardStatus](#keyboardstatus10)) => void | 是 | 回调函数,返回键盘状态。<br/>开发者需要在回调函数中根据传入的键盘状态做相应动作。 |
**错误码:** **错误码:**
...@@ -534,42 +1818,33 @@ stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -534,42 +1818,33 @@ stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800003 | Input method client error. | | 12800009 | Input method client is detached. |
| 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
try { try {
inputMethodController.stopInputSession((error, result) => { inputMethodController.on('sendKeyboardStatus', (keyBoardStatus) => {
if (error !== undefined) { console.info(`Succeeded in subscribing sendKeyboardStatus, keyBoardStatus: ${keyBoardStatus}`);
console.error('Failed to stopInputSession: ' + JSON.stringify(error));
return;
}
if (result) {
console.info('Succeeded in stopping inputSession.');
} else {
console.error('Failed to stopInputSession.');
}
}); });
} catch(error) { } catch(error) {
console.error('Failed to stopInputSession: ' + JSON.stringify(error)); console.error(`Failed to subscribe sendKeyboardStatus: ${JSON.stringify(error)}`);
} }
``` ```
### stopInputSession<sup>9+</sup> ### off('sendKeyboardStatus')<sup>10+</sup>
stopInputSession(): Promise&lt;boolean&gt; off(type: 'sendKeyboardStatus'): void
结束输入会话。通过点击输入框实现输入会话的开启之后此接口才可生效。使用promise异步回调 取消订阅输入法应用发送键盘状态事件
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
**返回值:** **参数:**
| 类型 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | | ------ | ------ | ---- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise对象。返回true表示结束输入会话成功;返回false表示结束输入会话失败。 | | type | string | 是 | 设置监听类型。<br/>-type为‘sendKeyboardStatus’时表示取消订阅输入法应用发送键盘状态事件监听。 |
**错误码:** **错误码:**
...@@ -577,42 +1852,33 @@ stopInputSession(): Promise&lt;boolean&gt; ...@@ -577,42 +1852,33 @@ stopInputSession(): Promise&lt;boolean&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800003 | Input method client error. | | 12800009 | Input method client is detached. |
| 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
try { try {
inputMethodController.stopInputSession().then((result) => { inputMethodController.off('sendKeyboardStatus');
if (result) { console.info('Succeeded in unsubscribing sendKeyboardStatus.');
console.info('Succeeded in stopping inputSession.'); } catch(error) {
} else { console.error(`Failed to unsubscribe sendKeyboardStatus: ${JSON.stringify(error)}`);
console.error('Failed to stopInputSession.');
}
}).catch((err) => {
console.error('Failed to stopInputSession: ' + JSON.stringify(err));
})
} catch(err) {
console.error('Failed to stopInputSession: ' + JSON.stringify(err));
} }
``` ```
### showSoftKeyboard<sup>9+</sup> ### on('sendFunctionKey')<sup>10+</sup>
showSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
显示软键盘。需要与输入框绑定使用。当点击输入框后,才可通过该接口的调用显示出当前输入法的软键盘。使用callback异步回调。 on(type: 'sendFunctionKey', callback: (functionKey: FunctionKey) => void): void
**需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用 订阅输入法应用发送功能键事件。使用callback异步回调
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------- | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当软键盘显示成功。err为undefined,否则为错误对象。 | | type | string | 是 | 设置监听类型。<br/>-type为‘sendFunctionKey’时表示订阅输入法应用发送FunctionKey事件监听。 |
| callback | (functionKey: [FunctionKey](#functionkey10)) => void | 是 | 回调函数,返回输入法应用发送的FunctionKey对象。<br/>开发者需要在回调函数中根据传入的FunctionKey对象做相应的操作。 |
**错误码:** **错误码:**
...@@ -620,36 +1886,33 @@ showSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void ...@@ -620,36 +1886,33 @@ showSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800003 | Input method client error. | | 12800009 | Input method client is detached. |
| 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
inputMethodController.showSoftKeyboard((err) => { try {
if (err === undefined) { inputMethodController.on('sendFunctionKey', (functionKey) => {
console.info('Succeeded in showing softKeyboard.'); console.info(`Succeeded in subscribing sendFunctionKey, functionKey.enterKeyType: ${functionKey.enterKeyType}`);
} else { });
console.error('Failed to showSoftKeyboard: ' + JSON.stringify(err)); } catch(error) {
} console.error(`Failed to subscribe sendFunctionKey: ${JSON.stringify(error)}`);
}) }
``` ```
### showSoftKeyboard<sup>9+</sup> ### off('sendFunctionKey')<sup>10+</sup>
showSoftKeyboard(): Promise&lt;void&gt;
显示软键盘。需要与输入框绑定使用。当点击输入框后,才可通过该接口的调用显示出当前输入法的软键盘。使用Promise异步回调。 off(type: 'sendFunctionKey'): void
**需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用 取消订阅输入法应用发送FunctionKey事件
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
**返回值:** **参数:**
| 类型 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------------- | ------------------------- | | ------ | ------ | ---- | ------------------------------------------------------------ |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 | | type | string | 是 | 设置监听类型。<br/>-type为‘sendFunctionKey’时表示取消订阅输入法应用发送FunctionKey事件监听。 |
**错误码:** **错误码:**
...@@ -657,34 +1920,33 @@ showSoftKeyboard(): Promise&lt;void&gt; ...@@ -657,34 +1920,33 @@ showSoftKeyboard(): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800003 | Input method client error. | | 12800009 | Input method client is detached. |
| 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
inputMethodController.showSoftKeyboard().then(() => { try {
console.log('Succeeded in showing softKeyboard.'); inputMethodController.off('sendFunctionKey');
}).catch((err) => { console.info('Succeeded in unsubscribing sendFunctionKey.');
console.error('Failed to showSoftKeyboard: ' + JSON.stringify(err)); } catch(error) {
}); console.error(`Failed to unsubscribe sendFunctionKey: ${JSON.stringify(error)}`);
}
``` ```
### hideSoftKeyboard<sup>9+</sup> ### on('moveCursor')<sup>10+</sup>
hideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
隐藏软键盘。需要与输入框绑定使用。点击输入框后,才可以使用该接口的调用隐藏软键盘。使用callback异步回调。 on(type: 'moveCursor', callback: (direction: Direction) => void): void
**需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用 订阅输入法应用移动光标事件。使用callback异步回调
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------- | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当软键盘隐藏成功。err为undefined,否则为错误对象。 | | type | string | 是 | 设置监听类型。<br/>-type为‘moveCursor’时表示订阅输入法应用移动光标事件监听。 |
| callback | callback: (direction: [Direction<sup>10+</sup>](#direction10)) => void | 是 | 回调函数,返回光标信息。<br/>开发者需要在回调函数中根据传入的光标移动方向改变光标位置。 |
**错误码:** **错误码:**
...@@ -692,36 +1954,33 @@ hideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void ...@@ -692,36 +1954,33 @@ hideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800003 | Input method client error. | | 12800009 | Input method client is detached. |
| 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
inputMethodController.hideSoftKeyboard((err) => { try {
if (err === undefined) { inputMethodController.on('moveCursor', (direction) => {
console.info('Succeeded in hiding softKeyboard.'); console.info(`Succeeded in subscribing moveCursor, direction: ${direction}`);
} else { });
console.error('Failed to hideSoftKeyboard: ' + JSON.stringify(err)); } catch(error) {
} console.error(`Failed to subscribe moveCursor: ${JSON.stringify(error)}`);
}) }
``` ```
### hideSoftKeyboard<sup>9+</sup> ### off('moveCursor')<sup>10+</sup>
hideSoftKeyboard(): Promise&lt;void&gt;
隐藏软键盘。需要与输入框绑定使用。点击输入框后,才可以使用该接口的调用隐藏软键盘。使用Promise异步回调。 off(type: 'moveCursor'): void
**需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用 取消订阅输入法应用移动光标事件
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
**返回值:** **参数:**
| 类型 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------------- | ------------------------- | | ------ | ------ | ---- | ------------------------------------------------------------ |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 | | type | string | 是 | 设置监听类型。<br/>-type为‘moveCursor’时表示取消订阅输入法应用发送移动光标事件监听。 |
**错误码:** **错误码:**
...@@ -729,83 +1988,85 @@ hideSoftKeyboard(): Promise&lt;void&gt; ...@@ -729,83 +1988,85 @@ hideSoftKeyboard(): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800003 | Input method client error. | | 12800009 | Input method client is detached. |
| 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
inputMethodController.hideSoftKeyboard().then(() => { try {
console.log('Succeeded in hiding softKeyboard.'); inputMethodController.off('moveCursor');
}).catch((err) => { console.info('Succeeded in unsubscribing moveCursor.');
console.error('Failed to hideSoftKeyboard: ' + JSON.stringify(err)); } catch(error) {
}); console.error(`Failed to unsubscribe moveCursor: ${JSON.stringify(error)}`);
}
``` ```
### stopInput<sup>(deprecated)</sup> ### on('handleExtendAction')<sup>10+</sup>
stopInput(callback: AsyncCallback&lt;boolean&gt;): void
结束输入会话。通过点击输入框实现输入会话的开启之后该接口的调用才可生效。使用callback异步回调。 on(type: 'handleExtendAction', callback: (action: ExtendAction) => void): void
> **说明:** 订阅输入法应用发送扩展操作事件。使用callback异步回调。
>
> 从API version 6开始支持,从API version 9开始废弃, 建议使用[stopInputSession()](#stopinputsession9)替代。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当输入法隐藏成功,err为undefined,data为true;否则为错误对象。 | | type | string | 是 | 设置监听类型。<br/>-type为‘handleExtendAction’时表示订阅输入法应用发送扩展操作代码事件监听。 |
| callback | callback: (action: [ExtendAction](#extendaction10)) => void | 是 | 回调函数,返回扩展代码。<br/>开发者需要在回调函数中根据传入的扩展操作类型做相应的操作。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800009 | Input method client is detached. |
**示例:** **示例:**
```js ```js
inputMethodController.stopInput((error, result) => { try {
if (error !== undefined) { inputMethodController.on('handleExtendAction', (action) => {
console.error('Failed to stopInput: ' + JSON.stringify(error)); console.info(`Succeeded in subscribing handleExtendAction, action: ${action}`);
return; });
} } catch(error) {
if (result) { console.error(`Failed to subscribe handleExtendAction: ${JSON.stringify(error)}`);
console.info('Succeeded in stopping input.'); }
} else {
console.error('Failed to stopInput.');
}
});
``` ```
### stopInput<sup>(deprecated)</sup> ### off('handleExtendAction')<sup>10+</sup>
stopInput(): Promise&lt;boolean&gt;
结束输入会话。通过点击输入框实现输入会话的开启之后该接口的调用才可生效。使用promise异步回调。 off(type: 'handleExtendAction'): void
> **说明:** 取消订阅输入法应用发送扩展事件。
>
> 从API version 6开始支持,从API version 9开始废弃, 建议使用[stopInputSession()](#stopinputsession9)替代。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
**返回值:** **参数:**
| 类型 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | | ------ | ------ | ---- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise对象。返回true表示输入法隐藏成功;返回false表示输入法隐藏失败。 | | type | string | 是 | 设置监听类型。<br/>-type为‘handleExtendAction’时表示取消订阅输入法应用发送扩展代码事件监听。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800009 | Input method client is detached. |
**示例:** **示例:**
```js ```js
inputMethodController.stopInput().then((result) => { try {
if (result) { inputMethodController.off('handleExtendAction');
console.info('Succeeded in stopping input.'); console.info('Succeeded in unsubscribing handleExtendAction.');
} else { } catch(error) {
console.error('Failed to stopInput.'); console.error(`Failed to unsubscribe handleExtendAction: ${JSON.stringify(error)}`);
} }
}).catch((err) => {
console.error('Failed to stopInput: ' + err);
})
``` ```
### on('selectByRange')<sup>10+</sup> ### on('selectByRange')<sup>10+</sup>
...@@ -821,7 +2082,7 @@ on(type: 'selectByRange', callback: Callback&lt;Range&gt;): void ...@@ -821,7 +2082,7 @@ on(type: 'selectByRange', callback: Callback&lt;Range&gt;): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘selectByRange’时表示订阅输入法应用按范围选中文本事件监听。 | | type | string | 是 | 设置监听类型。<br/>-type为‘selectByRange’时表示订阅输入法应用按范围选中文本事件监听。 |
| callback | Callback&lt;[Range](./js-apis-inputmethod-InputMethodCommon.md#range)&gt; | 是 | 回调函数,返回需要选中的文本的范围。<br/>开发者需要在回调函数中根据传入的范围选中编辑框中相应文本。 | | callback | Callback&lt;[Range](#range10)&gt; | 是 | 回调函数,返回需要选中的文本的范围。<br/>开发者需要在回调函数中根据传入的范围选中编辑框中相应文本。 |
**示例:** **示例:**
...@@ -864,7 +2125,7 @@ on(type: 'selectByMovement', callback: Callback&lt;Movement&gt;): void ...@@ -864,7 +2125,7 @@ on(type: 'selectByMovement', callback: Callback&lt;Movement&gt;): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘selectByMovement’时表示订阅输入法应用按光标移动动作选中文本事件监听。 | | type | string | 是 | 设置监听类型。<br/>-type为‘selectByMovement’时表示订阅输入法应用按光标移动动作选中文本事件监听。 |
| callback | Callback&lt;[Movement](./js-apis-inputmethod-InputMethodCommon.md#movement)&gt; | 是 | 回调函数,返回需要选中的文本的范围。<br/>开发者需要在回调函数中根据传入的光标动作选中编辑框中相应文本。 | | callback | Callback&lt;[Movement](#movement10)&gt; | 是 | 回调函数,返回需要选中的文本的范围。<br/>开发者需要在回调函数中根据传入的光标动作选中编辑框中相应文本。 |
**示例:** **示例:**
...@@ -942,6 +2203,50 @@ off(type: 'imeChange', callback?: (inputMethodProperty: InputMethodProperty, inp ...@@ -942,6 +2203,50 @@ off(type: 'imeChange', callback?: (inputMethodProperty: InputMethodProperty, inp
inputMethodSetting.off('imeChange'); inputMethodSetting.off('imeChange');
``` ```
### on('imeShow'|'imeHide')<sup>9+</sup>
on(type: 'imeShow'|'imeHide', callback: (info: Array\<InputWindowInfo>) => void): void
订阅输入法软键盘显示或隐藏事件。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘imeShow’时表示订阅输入法软键盘显示事件。<br/>-type为‘imeHide’时表示订阅输入法软键盘隐藏事件。 |
| callback | (info: Array\<InputWindowInfo>) => void | 是 | 回调函数,返回输入法软键盘信息。 |
**示例:**
```js
inputMethodSetting.on('imeShow', (info) => {
console.info('Succeeded in subscribing imeShow event.');
});
```
### off('imeShow'|'imeHide')<sup>9+</sup>
off(type: 'imeShow'|'imeHide', callback?: (info: Array\<InputWindowInfo>) => void): void
取消订阅输入法软键盘显示或隐藏事件。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘imeShow’时表示取消订阅输入法软键盘显示事件。<br/>-type为‘imeHide’时表示取消订阅输入法软键盘隐藏事件。 |
| callback | (info: Array\<InputWindowInfo>) => void | 否 | 取消订阅的输入法软键盘的回调函数。 |
**示例:**
```js
inputMethodSetting.off('imeShow');
```
### listInputMethodSubtype<sup>9+</sup> ### listInputMethodSubtype<sup>9+</sup>
listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: AsyncCallback&lt;Array&lt;InputMethodSubtype&gt;&gt;): void listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: AsyncCallback&lt;Array&lt;InputMethodSubtype&gt;&gt;): void
......
...@@ -1441,6 +1441,53 @@ keyboardController.hideKeyboard().then(() => { ...@@ -1441,6 +1441,53 @@ keyboardController.hideKeyboard().then(() => {
}); });
``` ```
## ExtendAction<sup>10+</sup>
对编辑框中文本的扩展编辑操作类型。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
| 名称 | 值 |说明 |
| -------- | -------- |-------- |
| SELECT_ALL | 0 |全选。 |
| CUT | 3 |剪切。 |
| COPY | 4 |复制。 |
| PASTE | 5 |粘贴。 |
## Direction<sup>10+</sup>
输入法光标移动方向。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
| 名称 | 值 |说明 |
| -------- | -------- |-------- |
| CURSOR_UP | 1 |向上。 |
| CURSOR_DOWN | 2 |向下。 |
| CURSOR_LEFT | 3 |向左。 |
| CURSOR_RIGHT | 4 |向右。 |
## Range<sup>10+</sup>
描述选中文本的范围。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| start | number | 是 | 是 | 选中文本的首字符在编辑框的索引值。|
| end | number | 是 | 是 | 选中文本的末字符在编辑框的索引值。|
## Movement<sup>10+</sup>
描述进行选中文本动作时光标移动的方向。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| direction | [Direction](#direction10) | 是 | 是 | 进行选中文本动作时光标移动的方向。|
## InputClient<sup>9+</sup> ## InputClient<sup>9+</sup>
下列API示例中都需使用[on('inputStart')](#oninputstart9)回调获取到InputClient实例,再通过此实例调用对应方法。 下列API示例中都需使用[on('inputStart')](#oninputstart9)回调获取到InputClient实例,再通过此实例调用对应方法。
...@@ -2136,7 +2183,7 @@ selectByRange(range: Range, callback: AsyncCallback&lt;void&gt;): void ...@@ -2136,7 +2183,7 @@ selectByRange(range: Range, callback: AsyncCallback&lt;void&gt;): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| range | [Range](./js-apis-inputmethod-InputMethodCommon.md#range) | 是 | 选中文本的范围。 | | range | [Range](#range10) | 是 | 选中文本的范围。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当成功发送选中事件后,err为undefined,否则为错误对象。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当成功发送选中事件后,err为undefined,否则为错误对象。 |
**错误码:** **错误码:**
...@@ -2176,7 +2223,7 @@ selectByRange(range: Range): Promise&lt;void&gt; ...@@ -2176,7 +2223,7 @@ selectByRange(range: Range): Promise&lt;void&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | --------------------------------------------------------- | ---- | ---------------- | | ------ | --------------------------------------------------------- | ---- | ---------------- |
| range | [Range](./js-apis-inputmethod-InputMethodCommon.md#range) | 是 | 选中文本的范围。 | | range | [Range](#range10) | 是 | 选中文本的范围。 |
**返回值:** **返回值:**
...@@ -2219,7 +2266,7 @@ selectByMovement(movement: Movement, callback: AsyncCallback&lt;void&gt;): void ...@@ -2219,7 +2266,7 @@ selectByMovement(movement: Movement, callback: AsyncCallback&lt;void&gt;): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| movement | [Movement](./js-apis-inputmethod-InputMethodCommon.md#movement) | 是 | 选中时光标移动的方向。 | | movement | [Movement](#movement10) | 是 | 选中时光标移动的方向。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当成功发送选中事件后,err为undefined,否则为错误对象。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当成功发送选中事件后,err为undefined,否则为错误对象。 |
**错误码:** **错误码:**
...@@ -2259,7 +2306,7 @@ selectByMovement(movement: Movement): Promise&lt;void&gt; ...@@ -2259,7 +2306,7 @@ selectByMovement(movement: Movement): Promise&lt;void&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ---------------------- | | -------- | ------------------------------------------------------------ | ---- | ---------------------- |
| movement | [Movement](./js-apis-inputmethod-InputMethodCommon.md#movement) | 是 | 选中时光标移动的方向。 | | movement | [Movement](#movement10) | 是 | 选中时光标移动的方向。 |
**返回值:** **返回值:**
...@@ -2310,7 +2357,6 @@ getTextIndexAtCursor(callback: AsyncCallback&lt;number&gt;): void ...@@ -2310,7 +2357,6 @@ getTextIndexAtCursor(callback: AsyncCallback&lt;number&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ------------------------------ | | -------- | ------------------------------ |
| 401 | parameter error. |
| 12800003 | input method client error. | | 12800003 | input method client error. |
| 12800006 | Input method controller error. | | 12800006 | Input method controller error. |
...@@ -2359,6 +2405,89 @@ inputClient.getTextIndexAtCursor().then((index) => { ...@@ -2359,6 +2405,89 @@ inputClient.getTextIndexAtCursor().then((index) => {
}); });
``` ```
### sendExtendAction<sup>10+</sup>
sendExtendAction(action: ExtendAction, callback: AsyncCallback&lt;void&gt;): void
发送扩展编辑操作,输入法应用调用该接口通知编辑控件完成相应扩展操作。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
| action | [ExtendAction](#extendaction10) | 是 | 要发送的扩展操作。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。发送成功,err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | ------------------------------ |
| 12800003 | input method client error. |
| 12800006 | Input method controller error. |
**示例:**
```js
try {
inputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY, (err) => {
if (err !== undefined) {
console.error(`Failed to sendExtendAction: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in sending extend action.');
});
} catch(error) {
console.error(`Failed to sendExtendAction: ${JSON.stringify(error)}`);
}
```
### sendExtendAction<sup>10+</sup>
sendExtendAction(action: ExtendAction): Promise&lt;void&gt;
发送扩展编辑操作,输入法应用调用该接口通知编辑控件完成相应扩展操作。使用promise异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| action | [ExtendAction](#extendaction10) | 是 | 需要发送的扩展功能对应的枚举类型。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | --------------------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | ------------------------------ |
| 12800003 | Input method client error. |
| 12800006 | Input method controller error. |
**示例:**
```js
try {
inputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY).then(() => {
console.info('Succeeded in sending extend action.');
}).catch((err) => {
console.error(`Failed to sendExtendAction: ${JSON.stringify(err)}`);
});
} catch(error) {
console.error(`Failed to sendExtendAction: ${JSON.stringify(error)}`);
}
```
## EditorAttribute ## EditorAttribute
编辑框属性值。 编辑框属性值。
......
...@@ -58,23 +58,23 @@ Input method client error. ...@@ -58,23 +58,23 @@ Input method client error.
重新将输入法应用与三方应用进行绑定:将三方应用后台进程杀死,重新启动三方应用,通过点击对话框等方式触发输入法键盘的显示,若键盘正常显示,则问题解决。 重新将输入法应用与三方应用进行绑定:将三方应用后台进程杀死,重新启动三方应用,通过点击对话框等方式触发输入法键盘的显示,若键盘正常显示,则问题解决。
## 12800004 按键事件处理异常 ## 12800004 不是输入法应用
**错误信息** **错误信息**
Key event processing error. Not an input method extension.
**错误描述** **错误描述**
按键事件异常时,系统会报此错误码。 其他应用调用了仅支持输入法应用调用的接口时,系统会报此错误码。
**可能原因** **可能原因**
按键事件分发、消费、监听异常时会报错 在其他应用中调用了仅支持输入法应用调用的接口
**处理步骤** **处理步骤**
在输入法应用中调用此接口。
## 12800005 配置固化失败 ## 12800005 配置固化失败
...@@ -146,4 +146,24 @@ Input method manager service error. ...@@ -146,4 +146,24 @@ Input method manager service error.
**处理步骤** **处理步骤**
通过ps -A|grep inputmethod查看是否存在输入法服务的进程号,如果存在,则服务正常。 通过ps -A|grep inputmethod查看是否存在输入法服务的进程号,如果存在,则服务正常。
\ No newline at end of file
通过ps -A|grep inputmethod查看是否存在输入法服务的进程号,如果存在,则服务正常。
## 12800009 输入法客户端未绑定
**错误信息**
Input method client is detached.
**错误描述**
当前应用未绑定输入法应用。
**可能原因**
当前应用在没有绑定输入法的情况下执行了比如showTextInput、hideTextInput等操作。
**处理步骤**
先执行attach接口操作即可。
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册