Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
fc7c5062
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
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看板
提交
fc7c5062
编写于
10月 25, 2022
作者:
H
Hollokin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
输入法框架API资料修改
Signed-off-by:
N
Hollokin
<
taoyuxin2@huawei.com
>
上级
01291ea5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
375 addition
and
188 deletion
+375
-188
zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-ability.md
...v/reference/apis/js-apis-inputmethod-extension-ability.md
+0
-121
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
+217
-59
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
...plication-dev/reference/apis/js-apis-inputmethodengine.md
+158
-8
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-ability.md
浏览文件 @
fc7c5062
...
...
@@ -68,124 +68,3 @@ class InputMethodExt extends InputMethodExtensionAbility {
}
}
```
## InputMethodExtensionAbility.onRequest()
onRequest(want: Want, startId: number): void
Extension生命周期回调,在一个输入法extention开始时回调,执行输入法的相关操作。
**模型约束**
: 此接口仅可在Stage模型下使用。
**系统能力**
:SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-Want.md
)
| 是 | 当前Extension相关的Want类型信息,包括ability名称、bundle名称等。 |
| startId | number | 是 | 返回拉起次数。首次拉起初始值返回1,多次之后自动递增。 |
**示例:**
```
ts
class
InputMethodExt
extends
InputMethodExtensionAbility
{
onRequest
(
want
,
startId
)
{
console
.
log
(
'
onRequest, want:
'
+
want
.
abilityName
+
'
startId:
'
+
startId
);
}
}
```
## InputMethodExtensionAbility.onConnect()
onConnect(want: Want): rpc.RemoteObject
Extension生命周期回调,在输入法extention首次连接输入法ability时回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**系统能力**
:SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-Want.md
)
| 是 | 当前Extension相关的Want类型信息,包括ability名称、bundle名称等。 |
**返回值**
| 类型 | 说明 |
| ------------------------------- | ------------------------------------------------------------ |
| rpc.RemoteObject | 一个RemoteObject对象,用于和客户端进行通信。 |
**示例:**
```
ts
import
rpc
from
'
@ohos.rpc
'
class
StubTest
extends
rpc
.
RemoteObject
{
constructor
(
des
)
{
super
(
des
);
}
onConnect
(
code
,
data
,
reply
,
option
)
{
}
}
class
ServiceExt
extends
ServiceExtension
{
onConnect
(
want
)
{
console
.
log
(
'
onConnect , want:
'
+
want
.
abilityName
);
return
new
StubTest
(
"
test
"
);
}
}
```
## InputMethodExtensionAbility.onDisconnect()
onDisconnect(want: Want): void
Extension生命周期回调,在所有连接在输入法extention上的ability都断开的时候回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**系统能力**
:SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-Want.md
)
| 是 | 当前Extension相关的Want类型信息,包括ability名称、bundle名称等。 |
**示例:**
```
ts
class
InputMethodExt
extends
InputMethodExtensionAbility
{
onDisconnect
(
want
)
{
console
.
log
(
'
onDisconnect, want:
'
+
want
.
abilityName
);
}
}
```
## InputMethodExtensionAbility.onReconnect()
onReconnect(want: Want): void
Extension生命周期回调,在一个新的客户端去尝试连接输入法extention的时候回调(先前连接在extention上的客户端全部断开的情况下)。
**模型约束**
: 此接口仅可在Stage模型下使用。
**系统能力**
:SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-Want.md
)
| 是 | 当前Extension相关的Want类型信息,包括ability名称、bundle名称等。 |
**示例:**
```
ts
class
InputMethodExt
extends
InputMethodExtensionAbility
{
onReconnect
(
want
)
{
console
.
log
(
'
onReconnect, want:
'
+
want
.
abilityName
);
}
}
```
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
浏览文件 @
fc7c5062
...
...
@@ -22,7 +22,7 @@ import inputMethod from '@ohos.inputmethod';
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| MAX_TYPE_NUM | number | 是 | 否 | 可支持的最大输入法个数。 |
| EXCEPTION_PERMISSION
<sup>
9+
</sup>
| number | 是 | 否 | 错误码。详见
../errorcodes/errcode-inputmethod-framework.md
,下同 |
| EXCEPTION_PERMISSION
<sup>
9+
</sup>
| number | 是 | 否 | 错误码。详见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
,下同 |
| EXCEPTION_PARAMCHECK
<sup>
9+
</sup>
| number | 是 | 否 | 错误码。 |
| EXCEPTION_UNSUPPORTED
<sup>
9+
</sup>
| number | 是 | 否 | 错误码。 |
| EXCEPTION_PACKAGEMANAGER
<sup>
9+
</sup>
| number | 是 | 否 | 错误码。 |
...
...
@@ -45,12 +45,12 @@ import inputMethod from '@ohos.inputmethod';
| -------- | -------- | -------- | -------- | -------- |
| packageName
<sup>
(deprecated)
</sup>
| string | 是 | 否 | 包名。 |
| methodId
<sup>
(deprecated)
</sup>
| string | 是 | 否 | Ability名。 |
| name
<sup>
9+
</sup>
| string | 是 | 否 | 包名
,非必填项
。 |
| id
<sup>
9+
</sup>
| string | 是 | 否 | Ability名
,非必填项
。 |
| label
<sup>
9+
</sup>
| string | 是 | 否 | 输入法标签,非必填项。|
| name
<sup>
9+
</sup>
| string | 是 | 否 | 包名。 |
| id
<sup>
9+
</sup>
| string | 是 | 否 | Ability名。 |
| label
<sup>
9+
</sup>
| string | 是 | 否 | 输入法标签,非必填项。|
| icon
<sup>
9+
</sup>
| string | 是 | 否 | 输入法图标,非必填项。 |
| iconId
<sup>
9+
</sup>
| number | 是 | 否 | 输入法图标id,非必填项。 |
| extra
<sup>
9+
</sup>
| object | 是 | 否 | 输入法其他信息
,非必填项
。 |
| extra
<sup>
9+
</sup>
| object | 是 | 否 | 输入法其他信息。 |
## inputMethod.getController<sup>9+</sup>
...
...
@@ -58,8 +58,6 @@ getController(): InputMethodController
获取客户端实例
[
InputMethodController
](
#inputmethodcontroller
)
。
**模型约束**
: 此接口仅可在Stage模型下使用。
**系统能力**
:SystemCapability.MiscServices.InputMethodFramework
**返回值:**
...
...
@@ -68,9 +66,17 @@ getController(): InputMethodController
| ----------------------------------------------- | ------------------------ |
|
[
InputMethodController
](
#inputmethodcontroller
)
| 回调返回当前客户端实例。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | ------------------------------ |
| 12800006 | Input method controller error. |
**示例:**
```
t
s
```
j
s
let
InputMethodController
=
inputMethod
.
getController
();
```
...
...
@@ -80,8 +86,6 @@ getSetting(): InputMethodSetting
获取客户端设置实例
[
InputMethodSetting
](
#inputmethodsetting8
)
。
**模型约束**
: 此接口仅可在Stage模型下使用。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
**返回值:**
...
...
@@ -90,9 +94,17 @@ getSetting(): InputMethodSetting
| ----------------------------------------- | ---------------------------- |
|
[
InputMethodSetting
](
#inputmethodsetting8
)
| 回调返回当前客户端设置实例。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800007 | Input method settings extension error. |
**示例:**
```
t
s
```
j
s
let
InputMethodSetting
=
inputMethod
.
getSetting
();
```
...
...
@@ -102,8 +114,6 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback<boolea
切换输入法。使用callback异步回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**需要权限**
: ohos.permission.CONNECT_IME_ABILITY
**系统能力**
:SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -115,9 +125,18 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback<boolea
| target |
[
InputMethodProperty
](
#inputmethodproperty8
)
| 是 | 传入要切换的目标输入法。 |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当输入法切换成功,err为undefined,data为true;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. |
**示例:**
```
t
s
```
j
s
try
{
inputMethod
.
switchInputMethod
({
packageName
:
'
com.example.kikakeyboard
'
,
methodId
:
'
com.example.kikakeyboard
'
},
(
err
,
result
)
=>
{
if
(
err
)
{
...
...
@@ -139,8 +158,6 @@ switchInputMethod(target: InputMethodProperty): Promise<boolean>
切换输入法。使用promise异步回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**需要权限**
: ohos.permission.CONNECT_IME_ABILITY
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -157,9 +174,18 @@ switchInputMethod(target: InputMethodProperty): Promise<boolean>
| ----------------------------------------- | ---------------------------- |
| Promise
\<
boolean> | Promise对象。返回true表示切换输入法成功;返回false表示切换输入法失败。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. |
**示例:**
```
t
s
```
j
s
try
{
inputMethod
.
switchInputMethod
({
packageName
:
'
com.example.kikakeyboard
'
,
methodId
:
'
com.example.kikakeyboard
'
}).
then
((
result
)
=>
{
if
(
result
)
{
...
...
@@ -181,8 +207,6 @@ getCurrentInputMethod(): InputMethodProperty
获取当前输入法扩展应用,提供同步接口,返回当前输入法属性。
**模型约束**
: 此接口仅可在Stage模型下使用。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
**返回值:**
...
...
@@ -193,7 +217,7 @@ getCurrentInputMethod(): InputMethodProperty
**示例:**
```
t
s
```
j
s
let
currentIme
=
inputMethod
.
getCurrentInputMethod
();
```
...
...
@@ -203,8 +227,6 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb
在当前输入法应用内切换子类型。使用callback异步回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**需要权限**
: ohos.permission.CONNECT_IME_ABILITY
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -216,9 +238,18 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb
| target |
[
InputMethodSubtype
](
./js-apis-inputmethodsubtype.md#inputmethodsubtype
)
| 是 | 传入要切换的目标输入法子类型。 |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当输入法子类型切换成功,err为undefined,data为true;否则为错误对象。|
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. |
**示例:**
```
t
s
```
j
s
let
inputMethodSubtype
=
{
id
:
"
com.example.kikainput
"
,
label
:
"
ServiceExtAbility
"
...
...
@@ -246,8 +277,6 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise<boolean&
在当前输入法应用内切换子类型。使用promise异步回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**需要权限**
: ohos.permission.CONNECT_IME_ABILITY
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -264,9 +293,18 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise<boolean&
| ----------------------------------------- | ---------------------------- |
| Promise
\<
boolean> | Promise对象。返回true表示在当前输入法应用内切换子类型成功;返回false表示在当前输入法应用内切换子类型失败。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. |
**示例:**
```
t
s
```
j
s
let
inputMethodSubtype
=
{
id
:
"
com.example.kikainput
"
,
label
:
"
ServiceExtAbility
"
...
...
@@ -292,8 +330,6 @@ getCurrentInputMethodSubtype(): InputMethodSubtype
获取当前输入法子类型。
**模型约束**
: 此接口仅可在Stage模型下使用。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
**返回值:**
...
...
@@ -304,7 +340,7 @@ getCurrentInputMethodSubtype(): InputMethodSubtype
**示例:**
```
t
s
```
j
s
let
currentImeSubType
=
inputMethod
.
getCurrentInputMethodSubtype
();
```
...
...
@@ -314,8 +350,6 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
切换至指定输入法应用的指定子类型,用于跨输入法应用切换子类型。使用callback异步回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**需要权限**
: ohos.permission.CONNECT_IME_ABILITY
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -328,9 +362,18 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
|inputMethodSubtype |
[
InputMethodSubtype
](
./js-apis-inputmethodsubtype.md#inputmethodsubtype
)
| 是 | 传入要切换的目标输入法子类型。 |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当输入法和子类型切换成功,err为undefined,data为获取到的切换子类型结果true;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. |
**示例:**
```
t
s
```
j
s
let
inputMethodProperty
=
{
packageName
:
"
com.example.kikakeyboard
"
,
methodId
:
"
ServiceExtAbility
"
...
...
@@ -362,8 +405,6 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
切换至指定输入法应用的指定子类型,用于跨输入法应用切换子类型。使用promise异步回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**需要权限**
: ohos.permission.CONNECT_IME_ABILITY
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -381,9 +422,18 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
| ----------------------------------------- | ---------------------------- |
| Promise
\<
boolean> | Promise对象。返回true表示切换至指定输入法应用的指定子类型成功;返回false表示切换至指定输入法应用的指定子类型失败。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. |
**示例:**
```
t
s
```
j
s
let
inputMethodProperty
=
{
name
:
"
com.example.kikakeyboard
"
,
id
:
"
ServiceExtAbility
"
...
...
@@ -475,6 +525,15 @@ stopInputSession(callback: AsyncCallback<boolean>): void
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当输入法隐藏成功,err为undefined,data为true;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. |
**示例:**
```
js
...
...
@@ -509,6 +568,15 @@ stopInputSession(): Promise<boolean>
| -------- | -------- |
| Promise
<
boolean
>
| Promise对象。返回true表示输入法隐藏成功;返回false表示输入法隐藏失败。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. |
**示例:**
```
js
...
...
@@ -543,6 +611,15 @@ showSoftKeyboard(callback: AsyncCallback<void>): void
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当软键盘显示成功。err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. |
**示例:**
```
js
...
...
@@ -571,6 +648,15 @@ showSoftKeyboard(): Promise<void>
| ------------------- | ------------------------- |
| Promise
<
void
>
| Promise对象。无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. |
**示例:**
```
js
...
...
@@ -597,6 +683,15 @@ hideSoftKeyboard(callback: AsyncCallback<void>): void
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当软键盘隐藏成功。err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. |
**示例:**
```
js
...
...
@@ -625,6 +720,15 @@ hideSoftKeyboard(): Promise<void>
| ------------------- | ------------------------- |
| Promise
<
void
>
| Promise对象。无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. |
**示例:**
```
js
...
...
@@ -756,8 +860,6 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async
获取指定输入法应用的所有子类型。使用callback异步回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
**参数:**
...
...
@@ -767,9 +869,18 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async
| inputMethodProperty | InputMethodProperty| 是 | 指定获取子类型所属的输入法应用
| callback | Array
<
[
InputMethodSubtype
](./
js-apis-inputmethodsubtype.md#inputmethodsubtype
)
>
| 是 | 回调函数,返回指定输入法应用的所有子类型。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. |
**示例:**
```
t
s
```
j
s
let
inputMethodProperty
=
{
packageName
:
'
com.example.kikakeyboard
'
,
methodId
:
'
com.example.kikakeyboard
'
...
...
@@ -793,8 +904,6 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise<Arr
获取指定输入法应用的所有子类型。使用promise异步回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
**参数:**
...
...
@@ -809,9 +918,18 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise<Arr
| ----------------------------------------------------------- | ---------------------- |
| Promise
<Array
<[
InputMethodSubtype
](./
js-apis-inputmethodsubtype.md#inputmethodsubtype
)
>
> | Promise对象,返回已安装输入法子类型列表。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. |
**示例:**
```
t
s
```
j
s
let
inputMethodSubProperty
=
{
id
:
"
com.example.kikainput
"
,
label
:
"
ServiceExtAbility
"
...
...
@@ -833,8 +951,6 @@ listCurrentInputMethodSubtype(callback: AsyncCallback<Array<InputMethodSub
查询当前输入法应用的所有子类型。使用callback异步回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
**参数:**
...
...
@@ -843,9 +959,18 @@ listCurrentInputMethodSubtype(callback: AsyncCallback<Array<InputMethodSub
| -------- | -------------------------------------------------- | ---- | ---------------------- |
| callback | Array
<
[
InputMethodSubtype
](./
js-apis-inputmethodsubtype.md#inputmethodsubtype
)
>
| 是 | 回调函数,返回当前输入法应用的所有子类型。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. |
**示例:**
```
t
s
```
j
s
try
{
InputMethodSetting
.
listCurrentInputMethodSubtype
((
err
,
data
)
=>
{
if
(
err
)
{
...
...
@@ -865,8 +990,6 @@ listCurrentInputMethodSubtype(): Promise<Array<InputMethodSubtype>>
查询当前输入法的子类型列表。使用promise异步回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
**返回值:**
...
...
@@ -875,9 +998,18 @@ listCurrentInputMethodSubtype(): Promise<Array<InputMethodSubtype>>
| ----------------------------------------------------------- | ---------------------- |
| Promise
<Array
<[
InputMethodSubtype
](./
js-apis-inputmethodsubtype.md#inputmethodsubtype
)
>
> | Promise对象,返回当前输入法的子类型列表。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. |
**示例:**
```
t
s
```
j
s
try
{
InputMethodSetting
.
listCurrentInputMethodSubtype
().
then
((
data
)
=>
{
console
.
info
(
'
listCurrentInputMethodSubtype success
'
);
...
...
@@ -895,8 +1027,6 @@ getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethod
获取已激活/未激活输入法列表。参数enable取true,返回已激活输入法列表,取false返回未激活输入法列表。使用callback异步回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
**参数:**
...
...
@@ -906,9 +1036,18 @@ getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethod
| enable | boolean | 是 | 指定返回已激活/未激活。 |
| callback | Array
<
[
InputMethodProperty
](
#inputmethodproperty8
)
>
| 是 | 回调函数,返回已激活/未激活输入法列表。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. |
**示例:**
```
t
s
```
j
s
try
{
InputMethodSetting
.
getInputMethods
(
true
,
(
err
,
data
)
=>
{
if
(
err
)
{
...
...
@@ -928,8 +1067,6 @@ getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>>
获取已激活/未激活输入法列表。参数enable取true返回已激活输入法列表,取false返回未激活输入法列表。使用promise异步回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
**参数:**
...
...
@@ -938,6 +1075,15 @@ getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>>
| ------ | ------- | ---- | ----------------------- |
| enable | boolean | 是 | 指定返回已激活/未激活。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. |
**返回值:**
| 类型 | 说明 |
...
...
@@ -946,7 +1092,7 @@ getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>>
**示例:**
```
t
s
```
j
s
try
{
InputMethodSetting
.
getInputMethods
(
true
).
then
((
data
)
=>
{
console
.
info
(
'
getInputMethods success
'
);
...
...
@@ -964,8 +1110,6 @@ showOptionalInputMethods(callback: AsyncCallback<boolean>): void
显示输入法选择对话框。使用callback异步回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**需要权限**
: ohos.permission.CONNECT_IME_ABILITY
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -976,9 +1120,17 @@ showOptionalInputMethods(callback: AsyncCallback<boolean>): void
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当输入法选择对话框显示成功,err为undefined,data为true;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800008 | Input method settings extension error. |
**示例:**
```
t
s
```
j
s
try
{
InputMethodSetting
.
showOptionalInputMethods
((
err
)
=>
{
if
(
err
)
{
...
...
@@ -998,8 +1150,6 @@ showOptionalInputMethods(): Promise<boolean>
显示输入法选择对话框。使用promise异步回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**需要权限**
: ohos.permission.CONNECT_IME_ABILITY
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -1010,9 +1160,17 @@ showOptionalInputMethods(): Promise<boolean>
| -------- | -------- |
| Promise
<
boolean
>
| Promise对象。返回true表示输入法选择对话框显示成功;返回false表示输入法选择对话框显示失败。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800008 | Input method settings extension error. |
**示例:**
```
t
s
```
j
s
InputMethodSetting
.
showOptionalInputMethods
().
then
(()
=>
{
console
.
info
(
'
displayOptionalInputMethod success.
'
);
}).
catch
((
err
)
=>
{
...
...
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
浏览文件 @
fc7c5062
...
...
@@ -801,6 +801,14 @@ hide(callback: AsyncCallback<void>): void
| -------- | ---------------------- | ---- | -------- |
| callback | AsyncCallback
<
void> | 否 | 回调函数。当输入法隐藏成功,err为undefined,否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800003 | Input method client error. |
**示例:**
```
js
...
...
@@ -827,6 +835,14 @@ hide(): Promise<void>
| ---------------- | ------------------------- |
| Promise
<
void> | Promise对象。无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800003 | Input method client error. |
**示例:**
```
js
...
...
@@ -916,7 +932,15 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void
| action | number | 是 | 编辑框属性。 |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当功能键发送成功,err为undefined,data为true;否则为错误对象。 |
**示例:**
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800003 | Input method client error. |
**示例:**
```
js
try
{
...
...
@@ -956,6 +980,14 @@ sendKeyFunction(action:number): Promise<boolean>
| ------------------------------- | ------------------------------------------------------------ |
| Promise
<
boolean
>
| Promise对象。返回true表示功能键发送成功;返回false表示功能键发送失败。|
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800003 | Input method client error. |
**示例:**
```
js
...
...
@@ -989,6 +1021,15 @@ getForward(length:number, callback: AsyncCallback<string>): void
| length | number | 是 | 文本长度。 |
| callback | AsyncCallback
<
string
>
| 是 | 回调函数。当光标前固定长度的文本获取成功,err为undefined,data为获取到的文本;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | ------------------------------ |
| 12800003 | Input method client error. |
| 12800006 | Input method controller error. |
**示例:**
```
js
...
...
@@ -1026,6 +1067,15 @@ getForward(length:number): Promise<string>
| ------------------------------- | ------------------------------------------------------------ |
| Promise
<
string
>
| Promise对象,返回光标前固定长度的文本。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | ------------------------------ |
| 12800003 | Input method client error. |
| 12800006 | Input method controller error. |
**示例:**
```
js
...
...
@@ -1058,6 +1108,15 @@ getBackward(length:number, callback: AsyncCallback<string>): void
| length | number | 是 | 文本长度。 |
| callback | AsyncCallback
<
string
>
| 是 | 回调函数。当光标后固定长度的文本获取成功,err为undefined,data为获取到的文本;否则为错误对象。|
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | ------------------------------ |
| 12800003 | Input method client error. |
| 12800006 | Input method controller error. |
**示例:**
```
js
...
...
@@ -1095,6 +1154,15 @@ getBackward(length:number): Promise<string>
| ------------------------------- | ------------------------------------------------------------ |
| Promise
<
string
>
| Promise对象,返回光标后固定长度的文本。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | ------------------------------ |
| 12800003 | Input method client error. |
| 12800006 | Input method controller error. |
**示例:**
```
js
...
...
@@ -1127,6 +1195,15 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void
| length | number | 是 | 文本长度。 |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当光标前固定长度的文本删除成功,err为undefined,data为true;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800002 | Input method engine error. |
| 12800003 | Input method client error. |
**示例:**
```
js
...
...
@@ -1168,6 +1245,15 @@ deleteForward(length:number): Promise<boolean>
| ---------------------- | -------------- |
| Promise
<
boolean
>
| Promise对象。返回true表示删除光标前固定长度的文本成功;返回false表示删除光标前固定长度的文本失败。|
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800002 | Input method engine error. |
| 12800003 | Input method client error. |
**示例:**
```
js
...
...
@@ -1204,7 +1290,16 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void
| length | number | 是 | 文本长度。 |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当光标后固定长度的文本删除成功,err为undefined,data为true;否则为错误对象。 |
**示例:**
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800002 | Input method engine error. |
| 12800003 | Input method client error. |
**示例:**
```
js
let
length
=
1
;
...
...
@@ -1245,6 +1340,15 @@ deleteBackward(length:number): Promise<boolean>
| ------------------------------- | ------------------------------------------------------------ |
| Promise
<
boolean
>
| Promise对象。返回true表示删除光标后固定长度的文本成功;返回false表示删除光标后固定长度的文本失败。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800002 | Input method engine error. |
| 12800003 | Input method client error. |
**示例:**
```
js
...
...
@@ -1277,6 +1381,15 @@ insertText(text:string, callback: AsyncCallback<boolean>): void
| text | string | 是 | 文本。 |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当文本插入成功,err为undefined,data为true;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800002 | Input method engine error. |
| 12800003 | Input method client error. |
**示例:**
```
js
...
...
@@ -1313,6 +1426,15 @@ insertText(text:string): Promise<boolean>
| ------------------------------- | ------------------------------------------------------------ |
| Promise
<
boolean
>
| Promise对象。返回true表示插入文本成功;返回false表示插入文本失败。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800002 | Input method engine error. |
| 12800003 | Input method client error. |
**示例:**
```
js
...
...
@@ -1347,6 +1469,14 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void
| ------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| callback | AsyncCallback
<
[EditorAttribute](#EditorAttribute)
>
| 是 | 回调函数。当编辑框属性值获取成功,err为undefined,data为编辑框属性值;否则为错误对象。|
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800003 | Input method client error. |
**示例:**
```
js
...
...
@@ -1374,6 +1504,14 @@ getEditorAttribute(): Promise<EditorAttribute>
| ------------------------------- | ------------------------------------------------------------ |
| Promise
<
[EditorAttribute](#editorattribute)
>
| Promise对象,返回编辑框属性值。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800003 | Input method client error. |
**示例:**
```
js
...
...
@@ -1393,8 +1531,6 @@ moveCursor(direction: number, callback: AsyncCallback<void>): void
移动光标。使用callback异步回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
**参数:**
...
...
@@ -1404,9 +1540,17 @@ moveCursor(direction: number, callback: AsyncCallback<void>): void
| direction | number | 是 | 光标移动方向。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当光标移动成功,err为undefined,否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800003 | Input method client error. |
**示例:**
```
t
s
```
j
s
try
{
InputClient
.
moveCursor
(
inputMethodAbility
.
CURSOR_xxx
,
(
err
)
=>
{
if
(
err
)
{
...
...
@@ -1426,8 +1570,6 @@ moveCursor(direction: number): Promise<void>
移动光标。使用promise异步回调。
**模型约束**
: 此接口仅可在Stage模型下使用。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
**参数:**
...
...
@@ -1442,9 +1584,17 @@ moveCursor(direction: number): Promise<void>
| ------------------- | ------------------------- |
| Promise
<
void
>
| Promise对象。无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errcode-inputmethod-framework.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800003 | Input method client error. |
**示例:**
```
t
s
```
j
s
async
function
InputMethodAbility
()
{
try
{
await
InputClient
.
moveCursor
(
inputMethodEngine
.
CURSOR_xxx
).
then
((
err
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录