From bb6f45dc2ba1b58bb6a5cea77e78c5653eacc8a2 Mon Sep 17 00:00:00 2001 From: Hollokin Date: Thu, 8 Dec 2022 16:25:19 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=BE=93=E5=85=A5=E6=B3=95=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E3=80=91API=E5=8F=82=E8=80=83=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hollokin --- .../apis/js-apis-inputmethod-subtype.md | 2 +- .../reference/apis/js-apis-inputmethod.md | 42 +++--- .../apis/js-apis-inputmethodengine.md | 140 +++++++++--------- 3 files changed, 94 insertions(+), 90 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethod-subtype.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethod-subtype.md index 8ce1a8bb6b..4a8d449923 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod-subtype.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod-subtype.md @@ -1,6 +1,6 @@ # 输入法子类型 -本模块提供对输入法子类型的属性管理。 +本模块提供对输入法子类型的属性管理。输入法应用子类型的含义,如:输入法的中文版、英文版、大写模式、小写模式等都属于输入法的子类型。 > **说明:** > 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 91d392c77f..9ae4dc9347 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @@ -31,14 +31,14 @@ import inputMethod from '@ohos.inputmethod'; | 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| packageName(deprecated) | string | 是 | 否 | 输入法包名。
**说明:** 从API8开始支持,从API9开始废弃,建议使用name替代。 | -| methodId(deprecated) | string | 是 | 否 | 输入法唯一标识。
**说明:** 从API8开始支持,从API9开始废弃,建议使用id替代。 | | name9+ | string | 是 | 否 | 输入法内部名称。 | | id9+ | string | 是 | 否 | 输入法唯一标识。 | | label9+ | string | 是 | 否 | 输入法对外显示名称。 | | icon9+ | string | 是 | 否 | 输入法图标数据。 | | iconId9+ | number | 是 | 否 | 输入法图标资源号。 | | extra9+ | object | 是 | 否 | 输入法扩展信息。 | +| packageName(deprecated) | string | 是 | 否 | 输入法包名。
**说明:** 从API version 8开始支持,从API version 9开始废弃,建议使用name替代。 | +| methodId(deprecated) | string | 是 | 否 | 输入法唯一标识。
**说明:** 从API version 8开始支持,从API version 9开始废弃,建议使用id替代。 | ## inputMethod.getController9+ @@ -505,7 +505,9 @@ getInputMethodSetting(): InputMethodSetting 获取客户端设置实例[InputMethodSetting](#inputmethodsetting8)。 -> **说明:**
从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实例,再通过此实例调用对应方法。 ### stopInputSession9+ stopInputSession(callback: AsyncCallback<boolean>): void -结束输入会话。使用callback异步回调。 +结束输入会话。通过点击输入框实现输入会话的开启之后该接口的调用才可生效。使用callback异步回调。 **系统能力:** SystemCapability.MiscServices.InputMethodFramework @@ -537,7 +539,7 @@ stopInputSession(callback: AsyncCallback<boolean>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| callback | AsyncCallback<boolean> | 是 | 回调函数。当输入法隐藏成功,err为undefined,data为true;否则为错误对象。 | +| callback | AsyncCallback<boolean> | 是 | 回调函数。当结束输入会话成功时,err为undefined,data为true;否则为错误对象。 | **错误码:** @@ -572,7 +574,7 @@ try { stopInputSession(): Promise<boolean> -结束输入会话。使用promise异步回调。 +结束输入会话。通过点击输入框实现输入会话的开启之后此接口才可生效。使用promise异步回调。 **系统能力:** SystemCapability.MiscServices.InputMethodFramework @@ -580,7 +582,7 @@ stopInputSession(): Promise<boolean> | 类型 | 说明 | | -------- | -------- | -| Promise<boolean> | Promise对象。返回true表示输入法隐藏成功;返回false表示输入法隐藏失败。 | +| Promise<boolean> | Promise对象。返回true表示结束输入会话成功;返回false表示结束输入会话失败。 | **错误码:** @@ -685,7 +687,7 @@ inputMethodController.showSoftKeyboard().then(async (err) => { hideSoftKeyboard(callback: AsyncCallback<void>): void -隐藏软键盘。使用callback异步回调。 +隐藏软键盘。需要与输入框绑定使用。点击输入框后,才可以使用该接口的调用隐藏软键盘。使用callback异步回调。 **需要权限:** ohos.permission.CONNECT_IME_ABILITY @@ -722,7 +724,7 @@ inputMethodController.hideSoftKeyboard((err) => { hideSoftKeyboard(): Promise<void> -隐藏软键盘,使用Promise异步回调。参数个数为0,否则抛出异常。 +隐藏软键盘。需要与输入框绑定使用。点击输入框后,才可以使用该接口的调用隐藏软键盘。使用Promise异步回调。 **需要权限:** ohos.permission.CONNECT_IME_ABILITY @@ -757,7 +759,7 @@ inputMethodController.hideSoftKeyboard().then(async (err) => { stopInput(callback: AsyncCallback<boolean>): void -结束输入会话。使用callback异步回调。 +结束输入会话。通过点击输入框实现输入会话的开启之后该接口的调用才可生效。使用callback异步回调。 > **说明:** > @@ -791,7 +793,7 @@ inputMethodController.stopInput((error, result) => { stopInput(): Promise<boolean> -结束输入会话。使用promise异步回调。 +结束输入会话。通过点击输入框实现输入会话的开启之后该接口的调用才可生效。使用promise异步回调。 > **说明:** > @@ -821,7 +823,7 @@ inputMethodController.stopInput().then((result) => { ## InputMethodSetting8+ -下列API示例中都需使用[getSetting](#inputmethodgetsetting9)回调获取到InputMethodSetting实例,再通过此实例调用对应方法。 +下列API示例中都需使用[getSetting](#inputmethodgetsetting9)获取到InputMethodSetting实例,再通过此实例调用对应方法。 ### on('imeChange')9+ @@ -879,7 +881,7 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------------- | ---- | ---------------------- | -| inputMethodProperty | InputMethodProperty| 是 | 指定获取子类型所属的输入法应用。 | +| inputMethodProperty | InputMethodProperty| 是 | 子类型所属的输入法应用。 | | callback | AsyncCallback<Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)>> | 是 | 回调函数,返回指定输入法应用的所有子类型。 | **错误码:** @@ -924,13 +926,13 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise<Arr | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------------- | ---- | ---------------------- | -| inputMethodProperty | InputMethodProperty| 是 | 指定获取子类型所属的输入法应用。 | +| inputMethodProperty | InputMethodProperty| 是 | 子类型所属的输入法应用。 | **返回值:** | 类型 | 说明 | | ----------------------------------------------------------- | ---------------------- | -| Promise> | Promise对象,返回已安装输入法子类型列表。 | +| Promise> | Promise对象,返回指定输入法应用的所有子类型。 | **错误码:** @@ -1011,7 +1013,7 @@ listCurrentInputMethodSubtype(): Promise<Array<InputMethodSubtype>> | 类型 | 说明 | | ----------------------------------------------------------- | ---------------------- | -| Promise> | Promise对象,返回当前输入法的子类型列表。 | +| Promise> | Promise对象,返回当前输入法应用的所有子类型。 | **错误码:** @@ -1040,7 +1042,7 @@ try { getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethodProperty>>): void -获取已激活/未激活输入法列表。参数enable取true,返回已激活输入法列表,取false返回未激活输入法列表。使用callback异步回调。 +获取已激活/未激活输入法列表。参数enable取true,返回已激活输入法列表,取false返回未激活输入法列表。已激活/未激活输入法的确切功能当前版本未支持。当前版本中,已激活输入法包括当前使用的输入法,未激活输入法包括当前输入法以外的其他已安装的输入法。使用callback异步回调。 **系统能力:** SystemCapability.MiscServices.InputMethodFramework @@ -1080,7 +1082,7 @@ try { getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>> -获取已激活/未激活输入法列表。参数enable取true返回已激活输入法列表,取false返回未激活输入法列表。使用promise异步回调。 +获取已激活/未激活输入法列表。参数enable取true,返回已激活输入法列表,取false返回未激活输入法列表。已激活/未激活输入法的确切功能当前版本未支持。当前版本中,已激活输入法包括当前使用的输入法,未激活输入法包括当前输入法以外的其他已安装的输入法。使用promise异步回调。 **系统能力:** SystemCapability.MiscServices.InputMethodFramework @@ -1289,7 +1291,7 @@ displayOptionalInputMethod(): Promise<void> > **说明:** > -> 从API version 8开始支持,API version 9开始废弃, 建议使用[showOptionalInputMethods()](#showoptionalinputmethods9-1)替代。 +> 从API version 8开始支持,从API version 9开始废弃, 建议使用[showOptionalInputMethods()](#showoptionalinputmethods9-1)替代。 **系统能力:** SystemCapability.MiscServices.InputMethodFramework diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md index f0123912f6..bed21d7425 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @@ -156,7 +156,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 设置监听类型。
-type为‘inputStart’时表示订阅输入法绑定。 | +| type | string | 是 | 设置监听类型。
- 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 | 是 | 设置监听类型。
-type为‘inputStart’时表示订阅输入法绑定。 | +| type | string | 是 | 设置监听类型。
- 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 | 是 | 设置监听类型。
- type为'keyboardShow',表示订阅输入法显示。
- type为'keyboardHide',表示订阅输入法隐藏。 | -| callback | () => void | 否 | 回调函数。 | +| callback | () => void | 否 | 回调函数。 | **示例:** @@ -259,8 +259,8 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, inputClient: | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 设置监听类型。
-type为‘inputStart’时表示订阅输入法绑定。 | -| callback | (kbController: [KeyboardController](#keyboardcontroller), textInputClient: [InputClient](#inputclient9)) => void | 是 | 回调函数,返回输入法操作相关实例。 | +| type | string | 是 | 设置监听类型。
- type为‘inputStart’时表示订阅输入法绑定。 | +| callback | (kbController: [KeyboardController](#keyboardcontroller), inputClient: [InputClient](#inputclient9)) => void | 是 | 回调函数,返回输入法操作相关实例。 | **示例:** @@ -283,8 +283,8 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, inputClien | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------ | -| type | string | 是 | 设置监听类型。
-type为‘inputStart’时表示订阅输入法绑定。 | -| callback | (kbController: [KeyboardController](#keyboardcontroller), textInputClient: [InputClient](#inputclient9)) => void | 否 | 回调函数,返回输入法操作相关实例。 | +| type | string | 是 | 设置监听类型。
- type为‘inputStart’时表示订阅输入法绑定。 | +| callback | (kbController: [KeyboardController](#keyboardcontroller), inputClient: [InputClient](#inputclient9)) => void | 否 | 回调函数,返回输入法操作相关实例。 | **示例:** @@ -306,7 +306,7 @@ on(type: 'inputStop', callback: () => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 设置监听类型。
-type为‘inputStop’时表示订阅停止输入法应用事件。 | +| type | string | 是 | 设置监听类型。
- type为‘inputStop’时表示订阅停止输入法应用事件。 | | callback | () => void | 是 | 回调函数。 | **示例:** @@ -329,7 +329,7 @@ off(type: 'inputStop', callback: () => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 设置监听类型。
-type为‘inputStop’时表示订阅停止输入法应用事件。 | +| type | string | 是 | 设置监听类型。
- type为‘inputStop’时表示订阅停止输入法应用事件。 | | callback | () => void | 是 | 回调函数。 | **示例:** @@ -342,7 +342,7 @@ inputMethodEngine.getInputMethodAbility().off('inputStop', () => { ### on('setCallingWindow')9+ -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 | 是 | 设置监听类型。
-type为‘setCallingWindow’时表示订阅设置调用窗口事件。 | -| callback | (wid:number) => void | 是 | 回调函数,返回调用方window id。 | +| type | string | 是 | 设置监听类型。
- type为‘setCallingWindow’时表示订阅设置调用窗口事件。 | +| callback | (wid: number) => void | 是 | 回调函数,返回调用方window id。 | **示例:** @@ -375,7 +375,7 @@ off(type: 'setCallingWindow', callback: (wid:number) => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 设置监听类型。
-type为‘setCallingWindow’时表示订阅设置调用窗口事件。 | +| type | string | 是 | 设置监听类型。
- type为‘setCallingWindow’时表示订阅设置调用窗口事件。 | | callback | (wid:number) => void | 是 | 回调函数,返回调用方window id。 | **示例:** @@ -398,7 +398,7 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 设置监听类型。
- type为'keyboardShow',表示订阅输入法显示。
- type为'keyboardHide',表示订阅输入法隐藏。 | +| type | string | 是 | 设置监听类型。
- type为'keyboardShow',表示订阅显示键盘事件。
- type为'keyboardHide',表示订阅隐藏键盘事件。 | | callback | () => void | 是 | 回调函数。 | **示例:** @@ -424,8 +424,8 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 设置监听类型。
- type为'keyboardShow',表示订阅输入法显示。
- type为'keyboardHide',表示订阅输入法隐藏。 | -| callback | () => void | 否 | 回调函数。 | +| type | string | 是 | 设置监听类型。
- type为'keyboardShow',表示取消订阅显示键盘事件。
- type为'keyboardHide',表示取消订阅隐藏键盘事件。 | +| callback | () => void | 否 | 回调函数。 | **示例:** @@ -448,10 +448,10 @@ on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => voi **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 设置监听类型。
- type为'setSubtype',表示订阅输入法子类型设置。
- type为'keyboardHide',表示订阅输入法隐藏。 | -| callback | (inputMethodSubtype: [InputMethodSubtype](js-apis-inputmethod-subtype.md)) => void | 是 | 回调函数,返回调用方的输入法子类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | 设置监听类型。
- type为'setSubtype',表示订阅输入法子类型的设置事件。 | +| callback | (inputMethodSubtype: [InputMethodSubtype](js-apis-inputmethod-subtype.md)) => void | 是 | 回调函数,返回设置的输入法子类型。 | **示例:** @@ -471,10 +471,10 @@ off(type: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => v **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 设置监听类型。
- type为'setSubtype',表示取消订阅输入法子类型设置。
- type为'keyboardHide',表示订阅输入法隐藏。 | -| callback | (inputMethodSubtype: [InputMethodSubtype](js-apis-inputmethod-subtype.md)) => void | 否 | 回调函数,返回调用方的输入法子类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | 设置监听类型。
- 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 | 是 | 设置监听类型。
- type为'keyDown',表示订阅硬键盘按下。
- type为'keyUp',表示订阅硬键盘抬起。 | +| type | string | 是 | 设置监听类型。
- type为'keyDown',表示订阅硬键盘按下事件。
- type为'keyUp',表示订阅硬键盘抬起事件。 | | callback | (event: [KeyEvent](#keyevent)) => boolean | 是 | 回调函数,返回按键信息。 | **示例:** @@ -528,10 +528,10 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 设置监听类型。
- type为'keyDown',表示订阅硬键盘按下。
- type为'keyUp',表示订阅硬键盘抬起。 | -| callback | (event: [KeyEvent](#keyevent)) => boolean | 否 | 回调函数,返回按键信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 设置监听类型。
- type为'keyDown',表示取消订阅硬键盘按下事件。
- 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 | 是 | 光标变化事件。
-type为’cursorContextChange‘时,表示光标变化。 | -| callback | (x: number, y:number, height:number) => void | 是 | 回调函数,返回光标信息。 | +**系统能力:** SystemCapability.MiscServices.InputMethodFramework +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 光标变化事件。
- type为’cursorContextChange‘时,表示订阅光标变化事件。 | +| callback | (x: number, y: number, height: number) => void | 是 | 回调函数,返回光标信息。
- x为光标上端的的x坐标值。
- y为光标上端的y坐标值。
- 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 | 是 | 光标变化事件。
-type为’cursorContextChange‘时,表示光标变化。 | -| callback | (x: number, y:number, height:number) => void | 否 | 回调函数,返回光标信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 光标变化事件。
- type为’cursorContextChange‘时,表示光标变化。 | +| callback | (x: number, y:number, height:number) => void | 否 | 回调函数,返回光标信息。
- x为光标上端的的x坐标值。
- y为光标上端的y坐标值。
- height为光标的高度值。
| **示例:** @@ -606,10 +604,10 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 文本选择变化事件。
-type为’selectionChange‘时,表示选择文本变化。 | -| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 是 | 回调函数,返回文本选择信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | 文本选择变化事件。
- type为’selectionChange‘时,表示选择文本变化。 | +| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 是 | 回调函数,返回文本选择信息。
- oldBegin为变化之前被选中文本的起始下标。
- oldEnd为变化之前被选中文本的终止下标。
- newBegin为变化之后被选中文本的起始下标。
- newEnd为变化之后被选中文本的终止下标。 | **示例:** @@ -630,14 +628,14 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe **系统能力:** SystemCapability.MiscServices.InputMethodFramework - **参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 文本选择变化事件。
-type为’selectionChange‘时,表示选择文本变化。 | -| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 否 | 回调函数,返回文本选择信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | 文本选择变化事件。
- type为’selectionChange‘时,表示选择文本变化。 | +| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 否 | 回调函数,返回文本选择信息。
- oldBegin为变化之前被选中文本的起始下标。
- oldEnd为变化之前被选中文本的终止下标。
- newBegin为变化之后被选中文本的起始下标。
- newEnd为变化之后被选中文本的终止下标。
| - **示例:** +**示例:** ```js inputMethodEngine.getKeyboardDelegate().off('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { @@ -658,8 +656,8 @@ on(type: 'textChange', callback: (text: string) => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 文本变化事件。
-type为’textChange‘时,表示当前文本变化。 | -| callback | (text: string) => void | 是 | 回调函数,返回当前文本内容。 | +| type | string | 是 | 文本变化事件。
- type为’textChange‘时,表示订阅文本变化事件。 | +| callback | (text: string) => void | 是 | 回调函数,返回订阅的文本内容。 | **示例:** @@ -677,14 +675,14 @@ off(type: 'textChange', callback?: (text: string) => void): void **系统能力:** SystemCapability.MiscServices.InputMethodFramework - **参数:** +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 文本变化事件。
-type为’textChange‘时,表示当前文本变化。 | -| callback | (text: string) => void | 否 | 回调函数,返回当前文本内容。 | +| type | string | 是 | 文本变化事件。
- type为’textChange‘时,表示取消订阅文本变化事件。 | +| callback | (text: string) => void | 否 | 回调函数,返回取消订阅的文本内容。 | - **示例:** +**示例:** ```js inputMethodEngine.getKeyboardDelegate().off('textChange', (text) => { @@ -836,7 +834,7 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| action | number | 是 | 编辑框属性。 | +| action | number | 是 | 功能键键值。
当值为0时,表示无效按键;
当值为1时,表示确认键(即回车键)。 | | callback | AsyncCallback<boolean> | 是 | 回调函数。当功能键发送成功,err为undefined,data为true;否则为错误对象。 | **错误码:** @@ -850,8 +848,9 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): 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 { ### sendKeyFunction9+ -sendKeyFunction(action:number): Promise<boolean> +sendKeyFunction(action: number): Promise<boolean> 发送功能键。使用promise异步回调。 @@ -879,7 +878,7 @@ sendKeyFunction(action:number): Promise<boolean> | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| action | number | 是 | 编辑框属性。 | +| action | number | 是 | 功能键键值。
当值为0时,表示无效按键;
当值为1时,表示确认键(即回车键)。 | **返回值:** @@ -898,8 +897,9 @@ sendKeyFunction(action:number): Promise<boolean> **示例:** ```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(deprecated) -sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void +sendKeyFunction(action: number, callback: AsyncCallback<boolean>): void 发送功能键。使用callback异步回调。 @@ -1830,13 +1830,14 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| action | number | 是 | 编辑框属性。 | +| action | number | 是 | 功能键键值。
当值为0时,表示无效按键;
当值为1时,表示确认键(即回车键)。 | | callback | AsyncCallback<boolean> | 是 | 回调函数。当功能键发送成功,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(deprecated) -sendKeyFunction(action:number): Promise<boolean> +sendKeyFunction(action: number): Promise<boolean> 发送功能键。使用promise异步回调。 @@ -1865,7 +1866,7 @@ sendKeyFunction(action:number): Promise<boolean> | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| action | number | 是 | 编辑框属性。 | +| action | number | 是 | 功能键键值。
当值为0时,表示无效按键;
当值为1时,表示确认键(即回车键)。 | **返回值:** @@ -1876,7 +1877,8 @@ sendKeyFunction(action:number): Promise<boolean> **示例:** ```js -TextInputClient.sendKeyFunction(keyFunction).then((result) => { +let action = 1; +TextInputClient.sendKeyFunction(action).then((result) => { if (result) { console.info('Success to sendKeyFunction. '); } else { -- GitLab