Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
bb6f45dc
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bb6f45dc
编写于
12月 08, 2022
作者:
H
Hollokin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【输入法框架】API参考内容优化改进
Signed-off-by:
N
Hollokin
<
taoyuxin2@huawei.com
>
上级
a003f6a5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
94 addition
and
90 deletion
+94
-90
zh-cn/application-dev/reference/apis/js-apis-inputmethod-subtype.md
...ication-dev/reference/apis/js-apis-inputmethod-subtype.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
+22
-20
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
...plication-dev/reference/apis/js-apis-inputmethodengine.md
+71
-69
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inputmethod-subtype.md
浏览文件 @
bb6f45dc
# 输入法子类型
本模块提供对输入法子类型的属性管理。
本模块提供对输入法子类型的属性管理。
输入法应用子类型的含义,如:输入法的中文版、英文版、大写模式、小写模式等都属于输入法的子类型。
> **说明:**
>
...
...
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
浏览文件 @
bb6f45dc
...
...
@@ -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
<
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) => {
## 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
<
Array
<
[
InputMethodSubtype
](./
js-apis-inputmethod-subtype.md#inputmethodsubtype
)
>
>
| 是 | 回调函数,返回指定输入法应用的所有子类型。 |
**错误码:**
...
...
@@ -924,13 +926,13 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise<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<Array<InputMethodSubtype>>
| 类型 | 说明 |
| ----------------------------------------------------------- | ---------------------- |
| 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
<
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
...
...
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
浏览文件 @
bb6f45dc
...
...
@@ -156,7 +156,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
-type为‘inputStart’时表示订阅输入法绑定。 |
| type | string | 是 | 设置监听类型。
<br/>
-
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/>
-
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/>
-
type为'keyboardShow',表示订阅输入法显示。
<br/>
-
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
)
,
textI
nputClient:
[
InputClient
](
#inputclient9
)
) => void | 是 | 回调函数,返回输入法操作相关实例。 |
| type | string | 是 | 设置监听类型。
<br/>
-
type为‘inputStart’时表示订阅输入法绑定。 |
| callback | (kbController:
[
KeyboardController
](
#keyboardcontroller
)
,
i
nputClient:
[
InputClient
](
#inputclient9
)
) => void | 是 | 回调函数,返回输入法操作相关实例。 |
**示例:**
...
...
@@ -283,8 +283,8 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, inputClien
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
-type为‘inputStart’时表示订阅输入法绑定。 |
| callback | (kbController:
[
KeyboardController
](
#keyboardcontroller
)
,
textI
nputClient:
[
InputClient
](
#inputclient9
)
) => void | 否 | 回调函数,返回输入法操作相关实例。 |
| type | string | 是 | 设置监听类型。
<br/>
-
type为‘inputStart’时表示订阅输入法绑定。 |
| callback | (kbController:
[
KeyboardController
](
#keyboardcontroller
)
,
i
nputClient:
[
InputClient
](
#inputclient9
)
) => void | 否 | 回调函数,返回输入法操作相关实例。 |
**示例:**
...
...
@@ -306,7 +306,7 @@ on(type: 'inputStop', callback: () => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
-type为‘inputStop’时表示订阅停止输入法应用事件。 |
| type | string | 是 | 设置监听类型。
<br/>
-
type为‘inputStop’时表示订阅停止输入法应用事件。 |
| callback | () => void | 是 | 回调函数。 |
**示例:**
...
...
@@ -329,7 +329,7 @@ off(type: 'inputStop', callback: () => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
-type为‘inputStop’时表示订阅停止输入法应用事件。 |
| type | string | 是 | 设置监听类型。
<br/>
-
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/>
-
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/>
-
type为‘setCallingWindow’时表示订阅设置调用窗口事件。 |
| callback | (wid:number) => void | 是 | 回调函数,返回调用方window id。 |
**示例:**
...
...
@@ -398,7 +398,7 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
-
type为'keyboardShow',表示订阅
输入法显示。
<br/>
-
type为'keyboardHide',表示订阅输入法隐藏
。 |
| type | string | 是 | 设置监听类型。
<br/>
-
type为'keyboardShow',表示订阅
显示键盘事件。
<br/>
-
type为'keyboardHide',表示订阅隐藏键盘事件
。 |
| callback | () => void | 是 | 回调函数。 |
**示例:**
...
...
@@ -424,8 +424,8 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
-
type为'keyboardShow',表示
订阅输入法显示。
<br/>
-
type为'keyboardHide',表示订阅输入法隐藏
。 |
| callback | () => void | 否 | 回调函数。
|
| type | string | 是 | 设置监听类型。
<br/>
-
type为'keyboardShow',表示
取消订阅显示键盘事件。
<br/>
-
type为'keyboardHide',表示取消订阅隐藏键盘事件
。 |
| callback | () => void | 否 | 回调函数。 |
**示例:**
...
...
@@ -448,10 +448,10 @@ on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => voi
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string
| 是 | 设置监听类型。
<br/>
-
type为'setSubtype',表示订阅输入法子类型设置。
<br/>
-
type为'keyboardHide',表示订阅输入法隐藏
。 |
| callback | (inputMethodSubtype:
[
InputMethodSubtype
](
js-apis-inputmethod-subtype.md
)
) => void
| 是 | 回调函数,返回调用方的输入法子类型。
|
| 参数名 | 类型
| 必填 | 说明 |
| -------- | ------
------------------------------------------------------
| ---- | ------------------------------------------------------------ |
| type | string
| 是 | 设置监听类型。
<br/>
-
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/>
-
type为'setSubtype',表示取消订阅输入法子类型设置。
<br/>
-
type为'keyboardHide',表示订阅输入法隐藏
。 |
| callback | (inputMethodSubtype:
[
InputMethodSubtype
](
js-apis-inputmethod-subtype.md
)
) => void
| 否 | 回调函数,返回调用方的输入法子类型。
|
| 参数名 | 类型
| 必填 | 说明 |
| -------- | ------
------------------------------------------------------
| ---- | ------------------------------------------------------------ |
| type | string
| 是 | 设置监听类型。
<br/>
-
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/>
-
type为'keyDown',表示订阅硬键盘按下
。
<br/>
-
type为'keyUp',表示订阅硬键盘抬起
。 |
| type | string | 是 | 设置监听类型。
<br/>
-
type为'keyDown',表示订阅硬键盘按下
事件。
<br/>
-
type为'keyUp',表示订阅硬键盘抬起事件
。 |
| callback | (event:
[
KeyEvent
](
#keyevent
)
) => boolean | 是 | 回调函数,返回按键信息。 |
**示例:**
...
...
@@ -528,10 +528,10 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------------------------------------------ |
| type | string
| 是 | 设置监听类型。
<br/>
-
type为'keyDown',表示订阅硬键盘按下。
<br/>
-
type为'keyUp',表示订阅硬键盘抬起
。 |
| callback | (event:
[
KeyEvent
](
#keyevent
)
) => boolean | 否 | 回调函数,返回按键信息。
|
| 参数名 | 类型
| 必填 | 说明 |
| -------- | ---------------------
--------------------
| ---- | ------------------------------------------------------------ |
| type | string
| 是 | 设置监听类型。
<br/>
-
type为'keyDown',表示取消订阅硬键盘按下事件。
<br/>
-
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/>
-
type为’cursorContextChange‘时,表示订阅光标变化事件。 |
| callback | (x: number, y: number, height: number) => void | 是 | 回调函数,返回光标信息。
<br/>
-
x为光标上端的的x坐标值。
<br/>
-
y为光标上端的y坐标值。
<br/>
-
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/>
-
type为’cursorContextChange‘时,表示光标变化。 |
| callback | (x: number, y:number, height:number) => void | 否 | 回调函数,返回光标信息。
<br/>
-
x为光标上端的的x坐标值。
<br/>
-
y为光标上端的y坐标值。
<br/>
-
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/>
-
type为’selectionChange‘时,表示选择文本变化。 |
| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 是 | 回调函数,返回文本选择信息。
<br/>
-
oldBegin为变化之前被选中文本的起始下标。
<br/>
-
oldEnd为变化之前被选中文本的终止下标。
<br/>
-
newBegin为变化之后被选中文本的起始下标。
<br/>
-
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/>
-
type为’selectionChange‘时,表示选择文本变化。 |
| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 否 | 回调函数,返回文本选择信息。
<br/>
-
oldBegin为变化之前被选中文本的起始下标。
<br/>
-
oldEnd为变化之前被选中文本的终止下标。
<br/>
-
newBegin为变化之后被选中文本的起始下标。
<br/>
-
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/>
-
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/>
-
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 | 是 |
功能键键值。
<br/>
当值为0时,表示无效按键;
<br/>
当值为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
(
keyFun
ction
,
(
err
,
result
)
=>
{
InputClient
.
sendKeyFunction
(
a
ction
,
(
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
<
boolean
>
sendKeyFunction(action:
number): Promise
<
boolean
>
发送功能键。使用promise异步回调。
...
...
@@ -879,7 +878,7 @@ sendKeyFunction(action:number): Promise<boolean>
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| action | number | 是 |
编辑框属性
。 |
| action | number | 是 |
功能键键值。
<br/>
当值为0时,表示无效按键;
<br/>
当值为1时,表示确认键(即回车键)
。 |
**返回值:**
...
...
@@ -898,8 +897,9 @@ sendKeyFunction(action:number): Promise<boolean>
**示例:**
```
js
let
action
=
1
;
try
{
InputClient
.
sendKeyFunction
(
keyFun
ction
).
then
((
result
)
=>
{
InputClient
.
sendKeyFunction
(
a
ction
).
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
<
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 | 是 |
功能键键值。
<br/>
当值为0时,表示无效按键;
<br/>
当值为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<sup>(deprecated)</sup>
sendKeyFunction(action:number): Promise
<
boolean
>
sendKeyFunction(action:
number): Promise
<
boolean
>
发送功能键。使用promise异步回调。
...
...
@@ -1865,7 +1866,7 @@ sendKeyFunction(action:number): Promise<boolean>
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| action | number | 是 |
编辑框属性
。 |
| action | number | 是 |
功能键键值。
<br/>
当值为0时,表示无效按键;
<br/>
当值为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
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录