提交 bb6f45dc 编写于 作者: H Hollokin

【输入法框架】API参考内容优化改进

Signed-off-by: NHollokin <taoyuxin2@huawei.com>
上级 a003f6a5
# 输入法子类型
本模块提供对输入法子类型的属性管理。
本模块提供对输入法子类型的属性管理。输入法应用子类型的含义,如:输入法的中文版、英文版、大写模式、小写模式等都属于输入法的子类型。
> **说明:**
>
......
......@@ -31,14 +31,14 @@ import inputMethod from '@ohos.inputmethod';
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| packageName<sup>(deprecated)</sup> | string | 是 | 否 | 输入法包名。<br/>**说明:** 从API8开始支持,从API9开始废弃,建议使用name替代。 |
| methodId<sup>(deprecated)</sup> | string | 是 | 否 | 输入法唯一标识。<br/>**说明:** 从API8开始支持,从API9开始废弃,建议使用id替代。 |
| name<sup>9+</sup> | string | 是 | 否 | 输入法内部名称。 |
| id<sup>9+</sup> | string | 是 | 否 | 输入法唯一标识。 |
| label<sup>9+</sup> | string | 是 | 否 | 输入法对外显示名称。 |
| icon<sup>9+</sup> | string | 是 | 否 | 输入法图标数据。 |
| iconId<sup>9+</sup> | number | 是 | 否 | 输入法图标资源号。 |
| extra<sup>9+</sup> | object | 是 | 否 | 输入法扩展信息。 |
| packageName<sup>(deprecated)</sup> | string | 是 | 否 | 输入法包名。<br/>**说明:** 从API version 8开始支持,从API version 9开始废弃,建议使用name替代。 |
| methodId<sup>(deprecated)</sup> | string | 是 | 否 | 输入法唯一标识。<br/>**说明:** 从API version 8开始支持,从API version 9开始废弃,建议使用id替代。 |
## inputMethod.getController<sup>9+</sup>
......@@ -505,7 +505,9 @@ getInputMethodSetting(): InputMethodSetting
获取客户端设置实例[InputMethodSetting](#inputmethodsetting8)
> **说明:**<br />从API version 6开始支持,从API version 9开始废弃, 建议使用[getSetting()](#inputmethodgetsetting9)替代。
> **说明:**
>
> 从API version 6开始支持,从API version 9开始废弃, 建议使用[getSetting()](#inputmethodgetsetting9)替代。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
......@@ -523,13 +525,13 @@ let inputMethodSetting = inputMethod.getInputMethodSetting();
## InputMethodController
下列API示例中都需使用[getController](#inputmethodgetcontroller9)回调获取到InputMethodController实例,再通过此实例调用对应方法。
下列API示例中都需使用[getController](#inputmethodgetcontroller9)获取到InputMethodController实例,再通过此实例调用对应方法。
### stopInputSession<sup>9+</sup>
stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void
结束输入会话。使用callback异步回调。
结束输入会话。通过点击输入框实现输入会话的开启之后该接口的调用才可生效。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
......@@ -537,7 +539,7 @@ stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当输入法隐藏成功,err为undefined,data为true;否则为错误对象。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当结束输入会话成功时,err为undefined,data为true;否则为错误对象。 |
**错误码:**
......@@ -572,7 +574,7 @@ try {
stopInputSession(): Promise&lt;boolean&gt;
结束输入会话。使用promise异步回调。
结束输入会话。通过点击输入框实现输入会话的开启之后此接口才可生效。使用promise异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
......@@ -580,7 +582,7 @@ stopInputSession(): Promise&lt;boolean&gt;
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise对象。返回true表示输入法隐藏成功;返回false表示输入法隐藏失败。 |
| Promise&lt;boolean&gt; | Promise对象。返回true表示结束输入会话成功;返回false表示结束输入会话失败。 |
**错误码:**
......@@ -685,7 +687,7 @@ inputMethodController.showSoftKeyboard().then(async (err) => {
hideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
隐藏软键盘。使用callback异步回调。
隐藏软键盘。需要与输入框绑定使用。点击输入框后,才可以使用该接口的调用隐藏软键盘。使用callback异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY
......@@ -722,7 +724,7 @@ inputMethodController.hideSoftKeyboard((err) => {
hideSoftKeyboard(): Promise&lt;void&gt;
隐藏软键盘,使用Promise异步回调。参数个数为0,否则抛出异常
隐藏软键盘。需要与输入框绑定使用。点击输入框后,才可以使用该接口的调用隐藏软键盘。使用Promise异步回调
**需要权限:** ohos.permission.CONNECT_IME_ABILITY
......@@ -757,7 +759,7 @@ inputMethodController.hideSoftKeyboard().then(async (err) => {
stopInput(callback: AsyncCallback&lt;boolean&gt;): void
结束输入会话。使用callback异步回调。
结束输入会话。通过点击输入框实现输入会话的开启之后该接口的调用才可生效。使用callback异步回调。
> **说明:**
>
......@@ -791,7 +793,7 @@ inputMethodController.stopInput((error, result) => {
stopInput(): Promise&lt;boolean&gt;
结束输入会话。使用promise异步回调。
结束输入会话。通过点击输入框实现输入会话的开启之后该接口的调用才可生效。使用promise异步回调。
> **说明:**
>
......@@ -821,7 +823,7 @@ inputMethodController.stopInput().then((result) => {
## InputMethodSetting<sup>8+</sup>
下列API示例中都需使用[getSetting](#inputmethodgetsetting9)回调获取到InputMethodSetting实例,再通过此实例调用对应方法。
下列API示例中都需使用[getSetting](#inputmethodgetsetting9)获取到InputMethodSetting实例,再通过此实例调用对应方法。
### on('imeChange')<sup>9+</sup>
......@@ -879,7 +881,7 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------------- | ---- | ---------------------- |
| inputMethodProperty | InputMethodProperty| 是 | 指定获取子类型所属的输入法应用。 |
| inputMethodProperty | InputMethodProperty| 是 | 子类型所属的输入法应用。 |
| callback | AsyncCallback&lt;Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)>&gt; | 是 | 回调函数,返回指定输入法应用的所有子类型。 |
**错误码:**
......@@ -924,13 +926,13 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise&lt;Arr
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------------- | ---- | ---------------------- |
| inputMethodProperty | InputMethodProperty| 是 | 指定获取子类型所属的输入法应用。 |
| inputMethodProperty | InputMethodProperty| 是 | 子类型所属的输入法应用。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------------------- | ---------------------- |
| Promise<Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)>> | Promise对象,返回已安装输入法子类型列表。 |
| Promise<Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)>> | Promise对象,返回指定输入法应用的所有子类型。 |
**错误码:**
......@@ -1011,7 +1013,7 @@ listCurrentInputMethodSubtype(): Promise&lt;Array&lt;InputMethodSubtype&gt;&gt;
| 类型 | 说明 |
| ----------------------------------------------------------- | ---------------------- |
| Promise<Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)>> | Promise对象,返回当前输入法的子类型列表。 |
| Promise<Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)>> | Promise对象,返回当前输入法应用的所有子类型。 |
**错误码:**
......@@ -1040,7 +1042,7 @@ try {
getInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;): void
获取已激活/未激活输入法列表。参数enable取true,返回已激活输入法列表,取false返回未激活输入法列表。使用callback异步回调。
获取已激活/未激活输入法列表。参数enable取true,返回已激活输入法列表,取false返回未激活输入法列表。已激活/未激活输入法的确切功能当前版本未支持。当前版本中,已激活输入法包括当前使用的输入法,未激活输入法包括当前输入法以外的其他已安装的输入法。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
......@@ -1080,7 +1082,7 @@ try {
getInputMethods(enable: boolean): Promise&lt;Array&lt;InputMethodProperty&gt;&gt;
获取已激活/未激活输入法列表。参数enable取true返回已激活输入法列表,取false返回未激活输入法列表。使用promise异步回调。
获取已激活/未激活输入法列表。参数enable取true,返回已激活输入法列表,取false返回未激活输入法列表。已激活/未激活输入法的确切功能当前版本未支持。当前版本中,已激活输入法包括当前使用的输入法,未激活输入法包括当前输入法以外的其他已安装的输入法。使用promise异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
......@@ -1289,7 +1291,7 @@ displayOptionalInputMethod(): Promise&lt;void&gt;
> **说明:**
>
> 从API version 8开始支持,API version 9开始废弃, 建议使用[showOptionalInputMethods()](#showoptionalinputmethods9-1)替代。
> 从API version 8开始支持,API version 9开始废弃, 建议使用[showOptionalInputMethods()](#showoptionalinputmethods9-1)替代。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
......
......@@ -156,7 +156,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘inputStart’时表示订阅输入法绑定。 |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为‘inputStart’时表示订阅输入法绑定。 |
| callback | (kbController: [KeyboardController](#keyboardcontroller), textInputClient: [TextInputClient](#textinputclient)) => void | 是 | 回调函数,返回订阅输入法的KeyboardController和TextInputClient实例。 |
**示例:**
......@@ -180,7 +180,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘inputStart’时表示订阅输入法绑定。 |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为‘inputStart’时表示订阅输入法绑定。 |
| callback | (kbController: [KeyboardController](#keyboardcontroller), textInputClient: [TextInputClient](#textinputclient)) => void | 否 | 回调函数,返回取消订阅的KeyboardController和TextInputClient实例。 |
**示例:**
......@@ -230,7 +230,7 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为'keyboardShow',表示订阅输入法显示。<br/>-&nbsp;type为'keyboardHide',表示订阅输入法隐藏。 |
| callback | () => void | 否 | 回调函数。 |
| callback | () => void | 否 | 回调函数。 |
**示例:**
......@@ -259,8 +259,8 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, inputClient:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘inputStart’时表示订阅输入法绑定。 |
| callback | (kbController: [KeyboardController](#keyboardcontroller), textInputClient: [InputClient](#inputclient9)) => void | 是 | 回调函数,返回输入法操作相关实例。 |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为‘inputStart’时表示订阅输入法绑定。 |
| callback | (kbController: [KeyboardController](#keyboardcontroller), inputClient: [InputClient](#inputclient9)) => void | 是 | 回调函数,返回输入法操作相关实例。 |
**示例:**
......@@ -283,8 +283,8 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, inputClien
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘inputStart’时表示订阅输入法绑定。 |
| callback | (kbController: [KeyboardController](#keyboardcontroller), textInputClient: [InputClient](#inputclient9)) => void | 否 | 回调函数,返回输入法操作相关实例。 |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为‘inputStart’时表示订阅输入法绑定。 |
| callback | (kbController: [KeyboardController](#keyboardcontroller), inputClient: [InputClient](#inputclient9)) => void | 否 | 回调函数,返回输入法操作相关实例。 |
**示例:**
......@@ -306,7 +306,7 @@ on(type: 'inputStop', callback: () => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘inputStop’时表示订阅停止输入法应用事件。 |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为‘inputStop’时表示订阅停止输入法应用事件。 |
| callback | () => void | 是 | 回调函数。 |
**示例:**
......@@ -329,7 +329,7 @@ off(type: 'inputStop', callback: () => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘inputStop’时表示订阅停止输入法应用事件。 |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为‘inputStop’时表示订阅停止输入法应用事件。 |
| callback | () => void | 是 | 回调函数。 |
**示例:**
......@@ -342,7 +342,7 @@ inputMethodEngine.getInputMethodAbility().off('inputStop', () => {
### on('setCallingWindow')<sup>9+</sup>
on(type: 'setCallingWindow', callback: (wid:number) => void): void
on(type: 'setCallingWindow', callback: (wid: number) => void): void
订阅设置调用窗口事件。使用callback异步回调。
......@@ -352,8 +352,8 @@ on(type: 'setCallingWindow', callback: (wid:number) => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘setCallingWindow’时表示订阅设置调用窗口事件。 |
| callback | (wid:number) => void | 是 | 回调函数,返回调用方window id。 |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为‘setCallingWindow’时表示订阅设置调用窗口事件。 |
| callback | (wid: number) => void | 是 | 回调函数,返回调用方window id。 |
**示例:**
......@@ -375,7 +375,7 @@ off(type: 'setCallingWindow', callback: (wid:number) => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘setCallingWindow’时表示订阅设置调用窗口事件。 |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为‘setCallingWindow’时表示订阅设置调用窗口事件。 |
| callback | (wid:number) => void | 是 | 回调函数,返回调用方window id。 |
**示例:**
......@@ -398,7 +398,7 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为'keyboardShow',表示订阅输入法显示。<br/>-&nbsp;type为'keyboardHide',表示订阅输入法隐藏。 |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为'keyboardShow',表示订阅显示键盘事件。<br/>-&nbsp;type为'keyboardHide',表示订阅隐藏键盘事件。 |
| callback | () => void | 是 | 回调函数。 |
**示例:**
......@@ -424,8 +424,8 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为'keyboardShow',表示订阅输入法显示。<br/>-&nbsp;type为'keyboardHide',表示订阅输入法隐藏。 |
| callback | () => void | 否 | 回调函数。 |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为'keyboardShow',表示取消订阅显示键盘事件。<br/>-&nbsp;type为'keyboardHide',表示取消订阅隐藏键盘事件。 |
| callback | () => void | 否 | 回调函数。 |
**示例:**
......@@ -448,10 +448,10 @@ on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => voi
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为'setSubtype',表示订阅输入法子类型设置。<br/>-&nbsp;type为'keyboardHide',表示订阅输入法隐藏。 |
| callback | (inputMethodSubtype: [InputMethodSubtype](js-apis-inputmethod-subtype.md)) => void | 是 | 回调函数,返回调用方的输入法子类型。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为'setSubtype',表示订阅输入法子类型的设置事件。 |
| callback | (inputMethodSubtype: [InputMethodSubtype](js-apis-inputmethod-subtype.md)) => void | 是 | 回调函数,返回设置的输入法子类型。 |
**示例:**
......@@ -471,10 +471,10 @@ off(type: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => v
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为'setSubtype',表示取消订阅输入法子类型设置。<br/>-&nbsp;type为'keyboardHide',表示订阅输入法隐藏。 |
| callback | (inputMethodSubtype: [InputMethodSubtype](js-apis-inputmethod-subtype.md)) => void | 否 | 回调函数,返回调用方的输入法子类型。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为'setSubtype',表示取消订阅输入法子类型的设置事件。 |
| callback | (inputMethodSubtype: [InputMethodSubtype](js-apis-inputmethod-subtype.md)) => void | 否 | 回调函数,返回设置的输入法子类型。 |
**示例:**
......@@ -500,7 +500,7 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为'keyDown',表示订阅硬键盘按下<br/>-&nbsp;type为'keyUp',表示订阅硬键盘抬起。 |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为'keyDown',表示订阅硬键盘按下事件。<br/>-&nbsp;type为'keyUp',表示订阅硬键盘抬起事件。 |
| callback | (event: [KeyEvent](#keyevent)) => boolean | 是 | 回调函数,返回按键信息。 |
**示例:**
......@@ -528,10 +528,10 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为'keyDown',表示订阅硬键盘按下。<br/>-&nbsp;type为'keyUp',表示订阅硬键盘抬起。 |
| callback | (event: [KeyEvent](#keyevent)) => boolean | 否 | 回调函数,返回按键信息。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为'keyDown',表示取消订阅硬键盘按下事件。<br/>-&nbsp;type为'keyUp',表示取消订阅硬键盘抬起事件。 |
| callback | (event: [KeyEvent](#keyevent)) => boolean | 否 | 回调函数,返回按键信息。 |
**示例:**
......@@ -552,16 +552,14 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) =
订阅光标变化事件。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 光标变化事件。<br/>-type为’cursorContextChange‘时,表示光标变化。 |
| callback | (x: number, y:number, height:number) => void | 是 | 回调函数,返回光标信息。 |
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 光标变化事件。<br/>-&nbsp;type为’cursorContextChange‘时,表示订阅光标变化事件。 |
| callback | (x: number, y: number, height: number) => void | 是 | 回调函数,返回光标信息。<br/>-&nbsp;x为光标上端的的x坐标值。<br/>-&nbsp;y为光标上端的y坐标值。<br/>-&nbsp;height为光标的高度值。 |
**示例:**
......@@ -575,7 +573,7 @@ inputMethodEngine.getKeyboardDelegate().on('cursorContextChange', (x, y, height)
### off('cursorContextChange')
off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number) => void): void
off(type: 'cursorContextChange', callback?: (x: number, y: number, height: number) => void): void
取消订阅光标变化事件。使用callback异步回调。
......@@ -583,10 +581,10 @@ off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number)
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 光标变化事件。<br/>-type为’cursorContextChange‘时,表示光标变化。 |
| callback | (x: number, y:number, height:number) => void | 否 | 回调函数,返回光标信息。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 光标变化事件。<br/>-&nbsp;type为’cursorContextChange‘时,表示光标变化。 |
| callback | (x: number, y:number, height:number) => void | 否 | 回调函数,返回光标信息。<br/>-&nbsp;x为光标上端的的x坐标值。<br/>-&nbsp;y为光标上端的y坐标值。<br/>-&nbsp;height为光标的高度值。<br/> |
**示例:**
......@@ -606,10 +604,10 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 文本选择变化事件。<br/>-type为’selectionChange‘时,表示选择文本变化。 |
| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 是 | 回调函数,返回文本选择信息。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 文本选择变化事件。<br/>-&nbsp;type为’selectionChange‘时,表示选择文本变化。 |
| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 是 | 回调函数,返回文本选择信息。<br/>-&nbsp;oldBegin为变化之前被选中文本的起始下标。<br/>-&nbsp;oldEnd为变化之前被选中文本的终止下标。<br/>-&nbsp;newBegin为变化之后被选中文本的起始下标。<br/>-&nbsp;newEnd为变化之后被选中文本的终止下标。 |
**示例:**
......@@ -630,14 +628,14 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 文本选择变化事件。<br/>-type为’selectionChange‘时,表示选择文本变化。 |
| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 否 | 回调函数,返回文本选择信息。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 文本选择变化事件。<br/>-&nbsp;type为’selectionChange‘时,表示选择文本变化。 |
| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 否 | 回调函数,返回文本选择信息。<br/>-&nbsp;oldBegin为变化之前被选中文本的起始下标。<br/>-&nbsp;oldEnd为变化之前被选中文本的终止下标。<br/>-&nbsp;newBegin为变化之后被选中文本的起始下标。<br/>-&nbsp;newEnd为变化之后被选中文本的终止下标。<br/> |
**示例:**
**示例:**
```js
inputMethodEngine.getKeyboardDelegate().off('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
......@@ -658,8 +656,8 @@ on(type: 'textChange', callback: (text: string) => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 文本变化事件。<br/>-type为’textChange‘时,表示当前文本变化。 |
| callback | (text: string) => void | 是 | 回调函数,返回当前文本内容。 |
| type | string | 是 | 文本变化事件。<br/>-&nbsp;type为’textChange‘时,表示订阅文本变化事件。 |
| callback | (text: string) => void | 是 | 回调函数,返回订阅的文本内容。 |
**示例:**
......@@ -677,14 +675,14 @@ off(type: 'textChange', callback?: (text: string) => void): void
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 文本变化事件。<br/>-type为’textChange‘时,表示当前文本变化。 |
| callback | (text: string) => void | 否 | 回调函数,返回当前文本内容。 |
| type | string | 是 | 文本变化事件。<br/>-&nbsp;type为’textChange‘时,表示取消订阅文本变化事件。 |
| callback | (text: string) => void | 否 | 回调函数,返回取消订阅的文本内容。 |
**示例:**
**示例:**
```js
inputMethodEngine.getKeyboardDelegate().off('textChange', (text) => {
......@@ -836,7 +834,7 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| action | number | 是 | 编辑框属性。 |
| action | number | 是 | 功能键键值。<br/>当值为0时,表示无效按键;<br/>当值为1时,表示确认键(即回车键)。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当功能键发送成功,err为undefined,data为true;否则为错误对象。 |
**错误码:**
......@@ -850,8 +848,9 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
**示例:**
```js
let action = 1;
try {
InputClient.sendKeyFunction(keyFunction, (err, result) => {
InputClient.sendKeyFunction(action, (err, result) => {
if (err) {
console.error('sendKeyFunction err: ' + JSON.stringify(err));
return;
......@@ -869,7 +868,7 @@ try {
### sendKeyFunction<sup>9+</sup>
sendKeyFunction(action:number): Promise&lt;boolean&gt;
sendKeyFunction(action: number): Promise&lt;boolean&gt;
发送功能键。使用promise异步回调。
......@@ -879,7 +878,7 @@ sendKeyFunction(action:number): Promise&lt;boolean&gt;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| action | number | 是 | 编辑框属性。 |
| action | number | 是 | 功能键键值。<br/>当值为0时,表示无效按键;<br/>当值为1时,表示确认键(即回车键)。 |
**返回值:**
......@@ -898,8 +897,9 @@ sendKeyFunction(action:number): Promise&lt;boolean&gt;
**示例:**
```js
let action = 1;
try {
InputClient.sendKeyFunction(keyFunction).then((result) => {
InputClient.sendKeyFunction(action).then((result) => {
if (result) {
console.info('Success to sendKeyFunction. ');
} else {
......@@ -1816,7 +1816,7 @@ TextInputClient.deleteBackward(length).then((result) => {
```
### sendKeyFunction<sup>(deprecated)</sup>
sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
sendKeyFunction(action: number, callback: AsyncCallback&lt;boolean&gt;): void
发送功能键。使用callback异步回调。
......@@ -1830,13 +1830,14 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| action | number | 是 | 编辑框属性。 |
| action | number | 是 | 功能键键值。<br/>当值为0时,表示无效按键;<br/>当值为1时,表示确认键(即回车键)。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当功能键发送成功,err为undefined,data为true;否则为错误对象。 |
**示例:**
```js
TextInputClient.sendKeyFunction(keyFunction, (err, result) => {
let action = 1;
TextInputClient.sendKeyFunction(action, (err, result) => {
if (err === undefined) {
console.error('sendKeyFunction err: ' + JSON.stringify(err));
return;
......@@ -1851,7 +1852,7 @@ TextInputClient.sendKeyFunction(keyFunction, (err, result) => {
### sendKeyFunction<sup>(deprecated)</sup>
sendKeyFunction(action:number): Promise&lt;boolean&gt;
sendKeyFunction(action: number): Promise&lt;boolean&gt;
发送功能键。使用promise异步回调。
......@@ -1865,7 +1866,7 @@ sendKeyFunction(action:number): Promise&lt;boolean&gt;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| action | number | 是 | 编辑框属性。 |
| action | number | 是 | 功能键键值。<br/>当值为0时,表示无效按键;<br/>当值为1时,表示确认键(即回车键)。 |
**返回值:**
......@@ -1876,7 +1877,8 @@ sendKeyFunction(action:number): Promise&lt;boolean&gt;
**示例:**
```js
TextInputClient.sendKeyFunction(keyFunction).then((result) => {
let action = 1;
TextInputClient.sendKeyFunction(action).then((result) => {
if (result) {
console.info('Success to sendKeyFunction. ');
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册