Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
af32ae67
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看板
未验证
提交
af32ae67
编写于
5月 07, 2023
作者:
O
openharmony_ci
提交者:
Gitee
5月 07, 2023
浏览文件
操作
浏览文件
下载
差异文件
!17826 输入法框架资料需求:自绘控件
Merge pull request !17826 from Hollokin/master
上级
b1f3ca1d
17c82510
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
2216 addition
and
946 deletion
+2216
-946
zh-cn/application-dev/reference/apis/js-apis-inputmethod-InputMethodCommon.md
...v/reference/apis/js-apis-inputmethod-InputMethodCommon.md
+0
-41
zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-ability.md
...v/reference/apis/js-apis-inputmethod-extension-ability.md
+6
-6
zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-context.md
...v/reference/apis/js-apis-inputmethod-extension-context.md
+6
-8
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
+1610
-458
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
...plication-dev/reference/apis/js-apis-inputmethodengine.md
+570
-427
zh-cn/application-dev/reference/errorcodes/errorcode-inputmethod-framework.md
...v/reference/errorcodes/errorcode-inputmethod-framework.md
+24
-6
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inputmethod-InputMethodCommon.md
已删除
100644 → 0
浏览文件 @
b1f3ca1d
# InputMethodCommon
> **说明:**
> 本模块首批接口从API version 10 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
输入法框架接口定义的公共属性信息。
## Direction
光标移动方向类型枚举。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 值 | 说明 |
| ------------ | ---- | ---------- |
| CURSOR_UP | 1 | 光标上移。 |
| CURSOR_DOWN | 2 | 光标下移。 |
| CURSOR_LEFT | 3 | 光标左移。 |
| CURSOR_RIGHT | 4 | 光标右移。 |
## Range
描述选中文本的范围。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ----- | ------ | ---- | ---- | ---------------------------------- |
| start | number | 是 | 是 | 选中文本的首字符在编辑框的索引值。 |
| end | number | 是 | 是 | 选中文本的末字符在编辑框的索引值。 |
## Movement
描述进行选中文本动作时光标移动的方向。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------- | ----------------------- | ---- | ---- | ---------------------------------- |
| direction |
[
Direction
](
#direction
)
| 是 | 是 | 进行选中文本动作时光标移动的方向。 |
zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-ability.md
浏览文件 @
af32ae67
zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-context.md
浏览文件 @
af32ae67
...
@@ -44,8 +44,8 @@ destroy(callback: AsyncCallback\<void>): void
...
@@ -44,8 +44,8 @@ destroy(callback: AsyncCallback\<void>): void
**示例:**
**示例:**
```
js
```
js
this
.
context
.
destroy
((
err
)
=>
{
this
.
context
.
destroy
(()
=>
{
console
.
log
(
'
destroy result:
'
+
JSON
.
stringify
(
err
)
);
console
.
log
(
'
Succeeded in destroying context.
'
);
});
});
```
```
...
@@ -67,8 +67,6 @@ destroy(): Promise\<void>;
...
@@ -67,8 +67,6 @@ destroy(): Promise\<void>;
```
js
```
js
this
.
context
.
destroy
().
then
(()
=>
{
this
.
context
.
destroy
().
then
(()
=>
{
console
.
log
(
'
Succeed in destoring context.
'
);
console
.
log
(
'
Succeed in destroying context.
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
Failed to destory context:
'
+
JSON
.
stringify
(
error
));
});
});
```
```
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
浏览文件 @
af32ae67
...
@@ -31,13 +31,13 @@ import inputMethod from '@ohos.inputMethod';
...
@@ -31,13 +31,13 @@ import inputMethod from '@ohos.inputMethod';
| 名称 | 类型 | 可读 | 可写 | 说明 |
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- | -------- |
| name
<sup>
9+
</sup>
| string | 是 | 否 |
输入法内部名称。必填
。|
| name
<sup>
9+
</sup>
| string | 是 | 否 |
必填。输入法内部名称
。|
| id
<sup>
9+
</sup>
| string | 是 | 否 |
输入法唯一标识。必填
。|
| id
<sup>
9+
</sup>
| string | 是 | 否 |
必填。输入法唯一标识
。|
| label
<sup>
9+
</sup>
| string | 是 | 否 |
输入法对外显示名称。 非必填
。|
| label
<sup>
9+
</sup>
| string | 是 | 否 |
非必填。输入法对外显示名称
。|
| labelId
<sup>
10+
</sup>
| string | 是 | 否 |
输入法对外显示名称资源号。 非必填
。|
| labelId
<sup>
10+
</sup>
| string | 是 | 否 |
非必填。输入法对外显示名称资源号
。|
| icon
<sup>
9+
</sup>
| string | 是 | 否 |
输入法图标数据。非必填。
|
| icon
<sup>
9+
</sup>
| string | 是 | 否 |
非必填。输入法图标数据。
|
| iconId
<sup>
9+
</sup>
| number | 是 | 否 |
输入法图标资源号。非必填
。 |
| iconId
<sup>
9+
</sup>
| number | 是 | 否 |
非必填。输入法图标资源号
。 |
| extra
<sup>
9+
</sup>
| object | 是 | 是 | 输入法扩展信息。 非必填。
<br/>
**说明:**
从API version 10开始改为非必选参数
。|
| extra
<sup>
10+
</sup>
| object | 是 | 是 | 非必填。输入法扩展信息
。|
| packageName
<sup>
(deprecated)
</sup>
| string | 是 | 否 | 输入法包名。必填。
<br/>
**说明:**
从API version 8开始支持,从API version 9开始废弃,建议使用name替代。 |
| 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替代。 |
| methodId
<sup>
(deprecated)
</sup>
| string | 是 | 否 | 输入法唯一标识。必填。
<br/>
**说明:**
从API version 8开始支持,从API version 9开始废弃,建议使用id替代。 |
...
@@ -126,28 +126,21 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback<boolea
...
@@ -126,28 +126,21 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback<boolea
**示例:**
**示例:**
```
js
```
js
let
im
=
inputMethod
.
getCurrentInputMethod
();
let
currentIme
=
inputMethod
.
getCurrentInputMethod
();
let
prop
=
{
packageName
:
im
.
packageName
,
methodId
:
im
.
methodId
,
name
:
im
.
packageName
,
id
:
im
.
methodId
,
extra
:
{}
}
try
{
try
{
inputMethod
.
switchInputMethod
(
prop
,
(
err
,
result
)
=>
{
inputMethod
.
switchInputMethod
(
currentIme
,
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to switchInputMethod:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to switchInputMethod:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in switching inputmethod.
'
);
console
.
log
(
'
Succeeded in switching inputmethod.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to switchInputMethod.
'
);
console
.
error
(
'
Failed to switchInputMethod.
'
);
}
}
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to switchInputMethod:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to switchInputMethod:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
## inputMethod.switchInputMethod<sup>9+</sup>
## inputMethod.switchInputMethod<sup>9+</sup>
...
@@ -183,26 +176,19 @@ switchInputMethod(target: InputMethodProperty): Promise<boolean>
...
@@ -183,26 +176,19 @@ switchInputMethod(target: InputMethodProperty): Promise<boolean>
**示例:**
**示例:**
```
js
```
js
let
im
=
inputMethod
.
getCurrentInputMethod
();
let
currentIme
=
inputMethod
.
getCurrentInputMethod
();
let
prop
=
{
packageName
:
im
.
packageName
,
methodId
:
im
.
methodId
,
name
:
im
.
packageName
,
id
:
im
.
methodId
,
extra
:
{}
}
try
{
try
{
inputMethod
.
switchInputMethod
(
prop
).
then
((
result
)
=>
{
inputMethod
.
switchInputMethod
(
currentIme
).
then
((
result
)
=>
{
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in switching inputmethod.
'
);
console
.
log
(
'
Succeeded in switching inputmethod.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to switchInputMethod.
'
);
console
.
error
(
'
Failed to switchInputMethod.
'
);
}
}
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to switchInputMethod:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to switchInputMethod:
${
JSON
.
stringify
(
err
)}
`
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to switchInputMethod:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to switchInputMethod:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -226,7 +212,7 @@ getCurrentInputMethod(): InputMethodProperty
...
@@ -226,7 +212,7 @@ getCurrentInputMethod(): InputMethodProperty
let
currentIme
=
inputMethod
.
getCurrentInputMethod
();
let
currentIme
=
inputMethod
.
getCurrentInputMethod
();
```
```
## inputMethod.switchCurrentInputMethodSubtype<sup>
9
+</sup>
## inputMethod.switchCurrentInputMethodSubtype<sup>
10
+</sup>
switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallback
\<
boolean>): void
switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallback
\<
boolean>): void
...
@@ -267,22 +253,22 @@ try {
...
@@ -267,22 +253,22 @@ try {
iconId
:
0
,
iconId
:
0
,
extra
:
{}
extra
:
{}
},
(
err
,
result
)
=>
{
},
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to switchCurrentInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in switching currentInputMethodSubtype.
'
);
console
.
log
(
'
Succeeded in switching currentInputMethodSubtype.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype
'
);
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype
'
);
}
}
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to switchCurrentInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
## inputMethod.switchCurrentInputMethodSubtype<sup>
9
+</sup>
## inputMethod.switchCurrentInputMethodSubtype<sup>
10
+</sup>
switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise
<
boolean
>
switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise
<
boolean
>
...
@@ -329,15 +315,15 @@ try {
...
@@ -329,15 +315,15 @@ try {
extra
:
{}
extra
:
{}
}).
then
((
result
)
=>
{
}).
then
((
result
)
=>
{
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in switching currentInputMethodSubtype.
'
);
console
.
log
(
'
Succeeded in switching currentInputMethodSubtype.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype.
'
);
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype.
'
);
}
}
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to switchCurrentInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to switchCurrentInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -391,47 +377,1266 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
...
@@ -391,47 +377,1266 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
**示例:**
**示例:**
```
js
```
js
let
im
=
inputMethod
.
getCurrentInputMethod
();
let
currentIme
=
inputMethod
.
getCurrentInputMethod
();
let
imSubType
=
inputMethod
.
getCurrentInputMethodSubtype
();
let
imSubType
=
inputMethod
.
getCurrentInputMethodSubtype
();
try
{
try
{
inputMethod
.
switchCurrentInputMethodAndSubtype
(
im
,
imSubType
,
(
err
,
result
)
=>
{
inputMethod
.
switchCurrentInputMethodAndSubtype
(
currentIme
,
imSubType
,
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to switchCurrentInputMethodAndSubtype:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to switchCurrentInputMethodAndSubtype:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in switching currentInputMethodAndSubtype.
'
);
console
.
log
(
'
Succeeded in switching currentInputMethodAndSubtype.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to switchCurrentInputMethodAndSubtype.
'
);
console
.
error
(
'
Failed to switchCurrentInputMethodAndSubtype.
'
);
}
}
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to switchCurrentInputMethodAndSubtype:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
`Failed to switchCurrentInputMethodAndSubtype:
${
JSON
.
stringify
(
err
)}
`
);
}
```
## inputMethod.switchCurrentInputMethodAndSubtype<sup>9+</sup>
switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype): Promise
<
boolean
>
切换至指定输入法应用的指定子类型,用于跨输入法应用切换子类型。使用promise异步回调。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
|inputMethodProperty |
[
InputMethodProperty
](
#inputmethodproperty8
)
| 是 | 传入要切换的目标输入法。 |
|inputMethodSubtype |
[
InputMethodSubtype
](
./js-apis-inputmethod-subtype.md#inputmethodsubtype
)
| 是 | 传入要切换的目标输入法子类型。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------- | ---------------------------- |
| Promise
\<
boolean> | Promise对象。返回true表示切换至指定输入法应用的指定子类型成功;返回false表示切换至指定输入法应用的指定子类型失败。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method manager service error. |
**示例:**
```
js
let
currentIme
=
inputMethod
.
getCurrentInputMethod
();
let
imSubType
=
inputMethod
.
getCurrentInputMethodSubtype
();
try
{
inputMethod
.
switchCurrentInputMethodAndSubtype
(
currentIme
,
imSubType
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
log
(
'
Succeeded in switching currentInputMethodAndSubtype.
'
);
}
else
{
console
.
error
(
'
Failed to switchCurrentInputMethodAndSubtype.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to switchCurrentInputMethodAndSubtype:
${
JSON
.
stringify
(
err
)}
`
);
})
}
catch
(
err
)
{
console
.
error
(
`Failed to switchCurrentInputMethodAndSubtype:
${
JSON
.
stringify
(
err
)}
`
);
}
```
## inputMethod.getInputMethodController<sup>(deprecated)</sup>
getInputMethodController(): InputMethodController
获取客户端实例
[
InputMethodController
](
#inputmethodcontroller
)
。
> **说明:**
>
> 从API version 6开始支持,从API version 9开始废弃,建议使用[getController()](#inputmethodgetcontroller9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ------------------------ |
|
[
InputMethodController
](
#inputmethodcontroller
)
| 回调返回当前客户端实例。 |
**示例:**
```
js
let
inputMethodController
=
inputMethod
.
getInputMethodController
();
```
## inputMethod.getInputMethodSetting<sup>(deprecated)</sup>
getInputMethodSetting(): InputMethodSetting
获取客户端设置实例
[
InputMethodSetting
](
#inputmethodsetting8
)
。
> **说明:**
>
> 从API version 6开始支持,从API version 9开始废弃,建议使用[getSetting()](#inputmethodgetsetting9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| ----------------------------------------- | ---------------------------- |
|
[
InputMethodSetting
](
#inputmethodsetting8
)
| 回调返回当前客户端设置实例。 |
**示例:**
```
js
let
inputMethodSetting
=
inputMethod
.
getInputMethodSetting
();
```
## TextInputType<sup>10+</sup>
文本输入类型。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 值 |说明 |
| -------- | -------- |-------- |
| NONE | -1 |NONE。 |
| TEXT | 0 |文本类型。 |
| MULTILINE | 1 |多行类型。 |
| NUMBER | 2 |数字类型。 |
| PHONE | 3 |电话号码类型。 |
| DATETIME | 4 |日期类型。 |
| EMAIL_ADDRESS | 5 |邮箱地址类型。 |
| URL | 6 |链接类型。 |
| VISIBLE_PASSWORD | 7 |密码类型。 |
## EnterKeyType<sup>10+</sup>
输入法Enter键所代表的功能类型。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 值 |说明 |
| -------- | -------- |-------- |
| UNSPECIFIED | 0 |未指定。 |
| NONE | 1 |NONE。 |
| GO | 2 |前往。 |
| SEARCH | 3 |查找。 |
| SEND | 4 |发送。 |
| NEXT | 5 |下一步。 |
| DONE | 6 |完成。 |
| PREVIOUS | 7 |上一步。 |
## KeyboardStatus<sup>10+</sup>
输入法软键盘状态。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 值 |说明 |
| -------- | -------- |-------- |
| NONE | 0 |NONE。 |
| HIDE | 1 |隐藏状态。 |
| SHOW | 2 |显示状态。 |
## Direction<sup>10+</sup>
光标移动方向。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 值 |说明 |
| -------- | -------- |-------- |
| CURSOR_UP | 1 |向上。 |
| CURSOR_DOWN | 2 |向下。 |
| CURSOR_LEFT | 3 |向左。 |
| CURSOR_RIGHT | 4 |向右。 |
## ExtendAction<sup>10+</sup>
对编辑框中文本的扩展编辑操作类型。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 值 |说明 |
| -------- | -------- |-------- |
| SELECT_ALL | 0 |全选。 |
| CUT | 3 |剪切。 |
| COPY | 4 |复制。 |
| PASTE | 5 |粘贴。 |
## FunctionKey<sup>10+</sup>
输入法功能键类型。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| enterKeyType
<sup>
10+
</sup>
|
[
EnterKeyType
](
#enterkeytype10
)
| 是 | 是 | 输入法enter键类型。|
## InputAttribute<sup>10+</sup>
编辑框属性,包含文本输入类型,Enter键功能类型。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| textInputType
<sup>
10+
</sup>
|
[
TextInputType
](
#textinputtype10
)
| 是 | 是 | 文本输入类型。|
| enterKeyType
<sup>
10+
</sup>
|
[
EnterKeyType
](
#enterkeytype10
)
| 是 | 是 | Enter键功能类型。|
## TextConfig<sup>10+</sup>
编辑控件配置信息。编辑控件请求绑定输入法应用时传入,将编辑控件相关属性配置信息保存到输入法框架内。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| inputAttribute
<sup>
10+
</sup>
|
[
InputAttribute
](
#inputattribute10
)
| 是 | 是 | 编辑框属性。|
## CursorInfo<sup>10+</sup>
光标信息。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| left | number | 是 | 是 | 光标的left坐标。|
| top | number | 是 | 是 | 光标的top坐标。|
| width | number | 是 | 是 | 光标的宽度。|
| height | number | 是 | 是 | 光标的高度。|
## Range<sup>10+</sup>
描述选中文本的范围。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| start | number | 是 | 是 | 选中文本的首字符在编辑框的索引值。|
| end | number | 是 | 是 | 选中文本的末字符在编辑框的索引值。|
## Movement<sup>10+</sup>
描述进行选中文本动作时光标移动的方向。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| direction |
[
Direction
](
#direction10
)
| 是 | 是 | 进行选中文本动作时光标移动的方向。|
## InputMethodController
下列API示例中都需使用
[
getController
](
#inputmethodgetcontroller9
)
获取到InputMethodController实例,再通过此实例调用对应方法。
### attach<sup>10+</sup>
attach(showKeyboard: boolean, textConfig: TextConfig, callback: AsyncCallback
<
void
>
): void
用于自绘控件绑定输入法应用。使用callback异步回调。
必须先调用此接口完成自绘控件与输入法应用的绑定,才可以使用输入法框架的以下功能:显示、隐藏键盘;更新光标信息;更改编辑框选中范围;保存配置信息;监听处理由输入法应用发送的信息或命令等。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| showKeyboard | boolean | 是 | 绑定输入法成功后是否拉起输入法键盘。 |
| textConfig |
[
TextConfig
](
#textconfig10
)
| 是 | 编辑控件配置信息。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当绑定输入法成功后,err为undefined;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```
js
try
{
let
textConfig
:
inputMethod
.
TextConfig
=
{
inputAttribute
:
{
textInputType
:
0
,
enterKeyType
:
1
}
};
inputMethodController
.
attach
(
true
,
textConfig
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to attach:
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
console
.
log
(
'
Succeeded in attaching the inputMethod.
'
);
});
}
catch
(
err
)
{
console
.
error
(
`Failed to attach:
${
JSON
.
stringify
(
err
)}
`
);
}
```
### attach<sup>10+</sup>
attach(showKeyboard: boolean, textConfig: TextConfig): Promise
<
void
>
用于自绘控件绑定输入法应用。使用callback异步回调。
必须先调用此接口完成自绘控件与输入法应用的绑定,才可以使用输入法框架的以下功能:显示、隐藏键盘;更新光标信息;更改编辑框选中范围;保存配置信息;监听处理由输入法应用发送的信息或命令等。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| showKeyboard | boolean | 是 | 绑定输入法成功后是否拉起输入法键盘。 |
| textConfig |
[
TextConfig
](
#textconfig10
)
| 是 | 编辑框属性。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```
js
try
{
let
textConfig
:
inputMethod
.
TextConfig
=
{
inputAttribute
:
{
textInputType
:
0
,
enterKeyType
:
1
}
};
inputMethodController
.
attach
(
true
,
textConfig
).
then
(()
=>
{
console
.
log
(
'
Succeeded in attaching inputMethod.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to attach:
${
JSON
.
stringify
(
err
)}
`
);
})
}
catch
(
err
)
{
console
.
error
(
`Failed to attach:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
## inputMethod.switchCurrentInputMethodAndSubtype<sup>9+</sup>
### showTextInput<sup>10+</sup>
switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype): Promise
<
boolean
>
showTextInput(callback: AsyncCallback
<
void
>
): void
进入文本编辑状态。使用callback异步回调。
编辑控件与输入法应用绑定成功后,可调用该接口去拉起软键盘。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。若成功进入编辑状态,err为undefined;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```
js
inputMethodController
.
showTextInput
((
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to showTextInput:
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
console
.
log
(
'
Succeeded in showing the inputMethod.
'
);
});
```
### showTextInput<sup>10+</sup>
showTextInput(): Promise
<
void
>
进入文本编辑状态。使用promise异步回调。
编辑控件与输入法应用绑定成功后,可调用该接口去拉起软键盘。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```
js
inputMethodController
.
showTextInput
().
then
(()
=>
{
console
.
log
(
'
Succeeded in showing text input.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to showTextInput:
${
JSON
.
stringify
(
err
)}
`
);
});
```
### hideTextInput<sup>10+</sup>
hideTextInput(callback: AsyncCallback
<
void
>
): void
退出文本编辑状态。使用callback异步回调。
编辑控件可调用该接口退出编辑状态。若调用该接口时当前软键盘处于显示状态,则调用该接口后软键盘会被隐藏。
调用该接口不解除与输入法应用的绑定,再次调用
[
showTextInput
](
#showtextinput10
)
时,可重新进入编辑状态。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当成功退出编辑状态时,err为undefined;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```
js
inputMethodController
.
hideTextInput
((
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to hideTextInput:
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
console
.
log
(
'
Succeeded in hiding text input.
'
);
});
```
### hideTextInput<sup>10+</sup>
hideTextInput(): Promise
<
void
>
退出文本编辑状态。使用promise异步回调。
编辑控件可调用该接口退出编辑状态。若调用该接口时当前软键盘处于显示状态,则调用该接口后软键盘会被隐藏。
调用该接口不解除与输入法应用的绑定,再次调用
[
showTextInput
](
#showtextinput10
)
时,可重新进入编辑状态。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```
js
inputMethodController
.
hideTextInput
().
then
(()
=>
{
console
.
log
(
'
Succeeded in hiding inputMethod.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to hideTextInput:
${
JSON
.
stringify
(
err
)}
`
);
})
```
### detach<sup>10+</sup>
detach(callback: AsyncCallback
<
void
>
): void
解除与输入法应用的绑定。使用callback异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当解绑定输入法成功时,err为undefined;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```
js
inputMethodController
.
detach
((
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to detach:
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
console
.
log
(
'
Succeeded in detaching inputMethod.
'
);
});
```
### detach<sup>10+</sup>
detach(): Promise
<
void
>
解除与输入法应用的绑定。使用promise异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```
js
inputMethodController
.
detach
().
then
(()
=>
{
console
.
log
(
'
Succeeded in detaching inputMethod.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to detach:
${
JSON
.
stringify
(
err
)}
`
);
});
```
### setCallingWindow<sup>10+</sup>
setCallingWindow(windowId: number, callback: AsyncCallback
<
void
>
): void
设置要避让的窗口。使用callback异步回调。
比如:将当前绑定到输入法的应用程序的窗口ID通知系统,正确设置后,客户端所在的窗口可以避开输入法窗口。预留能力,当前暂不支持获取windowId。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| windowId | number | 是 | 要避让的窗口id。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当设置成功时,err为undefined;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```
js
try
{
let
windowId
:
number
=
2000
;
inputMethodController
.
setCallingWindow
(
windowId
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to setCallingWindow:
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
console
.
log
(
'
Succeeded in setting callingWindow.
'
);
});
}
catch
(
err
)
{
console
.
error
(
`Failed to setCallingWindow:
${
JSON
.
stringify
(
err
)}
`
);
}
```
### setCallingWindow<sup>10+</sup>
setCallingWindow(windowId: number): Promise
<
void
>
设置要避让的窗口。使用promise异步回调。
比如:将当前绑定到输入法的应用程序的窗口ID通知系统,正确设置后,客户端所在的窗口可以避开输入法窗口。预留能力,当前暂不支持获取windowId。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| windowId | number | 是 | 要避让的窗口id。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```
js
try
{
let
windowId
:
number
=
2000
;
inputMethodController
.
setCallingWindow
(
windowId
).
then
(()
=>
{
console
.
log
(
'
Succeeded in setting callingWindow.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to setCallingWindow:
${
JSON
.
stringify
(
err
)}
`
);
})
}
catch
(
err
)
{
console
.
error
(
`Failed to setCallingWindow:
${
JSON
.
stringify
(
err
)}
`
);
}
```
### updateCursor<sup>10+</sup>
updateCursor(cursorInfo: CursorInfo, callback: AsyncCallback
<
void
>
): void
更新当前编辑框内光标信息。使用callback异步回调。
当光标信息发生变化时,可调用该接口更新光标信息,从而被输入法应用感知到光标变化。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| cursorInfo |
[
CursorInfo
](
#cursorinfo10
)
| 是 | 光标信息。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当光标信息更新成功时,err为undefined;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```
js
try
{
inputMethodController
.
updateCursor
({
left
:
0
,
top
:
0
,
width
:
600
,
height
:
800
},
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to updateCursor:
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
console
.
log
(
'
Succeeded in updating cursorInfo.
'
);
});
}
catch
(
err
)
{
console
.
error
(
`Failed to updateCursor:
${
JSON
.
stringify
(
err
)}
`
);
}
```
### updateCursor<sup>10+</sup>
updateCursor(cursorInfo: CursorInfo): Promise
<
void
>
更新当前编辑控件内的光标信息。使用promise异步回调。
当光标信息发生变化时,编辑控件可调用该接口更新光标信息,从而被输入法应用感知到光标变化。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| cursorInfo |
[
CursorInfo
](
#cursorinfo10
)
| 是 | 光标信息。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```
js
try
{
inputMethodController
.
updateCursor
({
left
:
0
,
top
:
0
,
width
:
600
,
height
:
800
}).
then
(()
=>
{
console
.
log
(
'
Succeeded in updating cursorInfo.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to updateCursor:
${
JSON
.
stringify
(
err
)}
`
);
})
}
catch
(
err
)
{
console
.
error
(
`Failed to updateCursor:
${
JSON
.
stringify
(
err
)}
`
);
}
```
### changeSelection<sup>10+</sup>
changeSelection(text: string, start: number, end: number, callback: AsyncCallback
<
void
>
): void
向输入法应用更新当前编辑框内被选中的文本信息,当选中的文本内容或文本范围发生变化时,可调用该接口更新文本信息。使用callback异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| text | string | 是 | 整个输入文本。 |
| start | number | 是 | 所选文本的起始位置。 |
| end | number | 是 | 所选文本的结束位置。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当隐藏输入法成功时,err为undefined;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```
js
try
{
inputMethodController
.
changeSelection
(
'
text
'
,
0
,
5
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to changeSelection:
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
console
.
log
(
'
Succeeded in changing selection.
'
);
});
}
catch
(
err
)
{
console
.
error
(
`Failed to changeSelection:
${
JSON
.
stringify
(
err
)}
`
);
}
```
### changeSelection<sup>10+</sup>
changeSelection(text: string, start: number, end: number): Promise
<
void
>
向输入法应用更新当前编辑框内被选中的文本信息,当选中的文本内容或文本范围发生变化时,可调用该接口更新文本信息。使用promise异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| text | string | 是 | 整个输入文本。 |
| start | number | 是 | 所选文本的起始位置。 |
| end | number | 是 | 所选文本的结束位置。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```
js
try
{
inputMethodController
.
changeSelection
(
'
test
'
,
0
,
5
).
then
(()
=>
{
console
.
log
(
'
Succeeded in changing selection.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to changeSelection:
${
JSON
.
stringify
(
err
)}
`
);
})
}
catch
(
err
)
{
console
.
error
(
`Failed to changeSelection:
${
JSON
.
stringify
(
err
)}
`
);
}
```
### updateAttribute<sup>10+</sup>
updateAttribute(attribute: InputAttribute, callback: AsyncCallback
<
void
>
): void
更新编辑框属性配置信息。使用callback异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| attribute |
[
InputAttribute
](
#inputattribute10
)
| 是 | InputAttribute对象,包含的额外信息。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当隐藏输入法成功时,err为undefined;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```
js
try
{
inputMethodController
.
updateAttribute
({
textInputType
:
0
,
enterKeyType
:
1
},
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to updateAttribute:
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
console
.
log
(
'
Succeeded in updating attribute.
'
);
});
}
catch
(
err
)
{
console
.
error
(
`Failed to updateAttribute:
${
JSON
.
stringify
(
err
)}
`
);
}
```
### updateAttribute<sup>10+</sup>
updateAttribute(attribute: InputAttribute): Promise
<
void
>
更新编辑框属性配置信息。使用promise异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| attribute |
[
InputAttribute
](
#inputattribute10
)
| 是 | InputAttribute对象,包含的额外信息。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
| 12800009 | Input method client is detached. |
**示例:**
```
js
try
{
inputMethodController
.
updateAttribute
({
textInputType
:
0
,
enterKeyType
:
1
}).
then
(()
=>
{
console
.
log
(
'
Succeeded in updating attribute.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to updateAttribute:
${
JSON
.
stringify
(
err
)}
`
);
})
}
catch
(
err
)
{
console
.
error
(
`Failed to updateAttribute:
${
JSON
.
stringify
(
err
)}
`
);
}
```
### stopInputSession<sup>9+</sup>
stopInputSession(callback: AsyncCallback
<
boolean
>
): void
结束输入会话。使用callback异步回调。
需要与编辑控件(如:输入框)绑定使用。当点击编辑控件后,才可通过调用该接口结束输入会话。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当结束输入会话成功时,err为undefined,data为true;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```
js
try
{
inputMethodController
.
stopInputSession
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to stopInputSession:
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
if
(
result
)
{
console
.
log
(
'
Succeeded in stopping inputSession.
'
);
}
else
{
console
.
error
(
'
Failed to stopInputSession.
'
);
}
});
}
catch
(
err
)
{
console
.
error
(
`Failed to stopInputSession:
${
JSON
.
stringify
(
err
)}
`
);
}
```
### stopInputSession<sup>9+</sup>
stopInputSession(): Promise
<
boolean
>
结束输入会话。使用promise异步回调。
需要与编辑控件(如:输入框)绑定使用。当点击编辑控件后,才可通过调用该接口结束输入会话。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
boolean
>
| Promise对象。返回true表示结束输入会话成功;返回false表示结束输入会话失败。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```
js
try
{
inputMethodController
.
stopInputSession
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
log
(
'
Succeeded in stopping inputSession.
'
);
}
else
{
console
.
error
(
'
Failed to stopInputSession.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to stopInputSession:
${
JSON
.
stringify
(
err
)}
`
);
})
}
catch
(
err
)
{
console
.
error
(
`Failed to stopInputSession:
${
JSON
.
stringify
(
err
)}
`
);
}
```
### showSoftKeyboard<sup>9+</sup>
showSoftKeyboard(callback: AsyncCallback
<
void
>
): void
显示软键盘。使用callback异步回调。
需要与编辑控件(如:输入框)绑定使用。当点击编辑控件后,才可通过该接口的调用显示出当前输入法的软键盘。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当软键盘显示成功。err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```
js
inputMethodController
.
showSoftKeyboard
((
err
)
=>
{
if
(
!
err
)
{
console
.
log
(
'
Succeeded in showing softKeyboard.
'
);
}
else
{
console
.
error
(
`Failed to show softKeyboard:
${
JSON
.
stringify
(
err
)}
`
);
}
})
```
### showSoftKeyboard<sup>9+</sup>
showSoftKeyboard(): Promise
<
void
>
显示软键盘。使用Promise异步回调。
需要与编辑控件(如:输入框)绑定使用。当点击编辑控件后,才可通过该接口的调用显示出当前输入法的软键盘。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```
js
inputMethodController
.
showSoftKeyboard
().
then
(()
=>
{
console
.
log
(
'
Succeeded in showing softKeyboard.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to show softKeyboard:
${
JSON
.
stringify
(
err
)}
`
);
});
```
### hideSoftKeyboard<sup>9+</sup>
hideSoftKeyboard(callback: AsyncCallback
<
void
>
): void
隐藏软键盘。使用callback异步回调。
需要与编辑控件(如:输入框)绑定使用。当点击编辑控件后,才可通过调用该接口隐藏当前输入法的软键盘。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当软键盘隐藏成功。err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```
js
inputMethodController
.
hideSoftKeyboard
((
err
)
=>
{
if
(
!
err
)
{
console
.
log
(
'
Succeeded in hiding softKeyboard.
'
);
}
else
{
console
.
error
(
`Failed to hide softKeyboard:
${
JSON
.
stringify
(
err
)}
`
);
}
})
```
### hideSoftKeyboard<sup>9+</sup>
hideSoftKeyboard(): Promise
<
void
>
隐藏软键盘。使用Promise异步回调。
需要与编辑控件(如:输入框)绑定使用。当点击编辑控件后,才可通过调用该接口隐藏当前输入法的软键盘。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method manager service error. |
**示例:**
```
js
inputMethodController
.
hideSoftKeyboard
().
then
(()
=>
{
console
.
log
(
'
Succeeded in hiding softKeyboard.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to hide softKeyboard:
${
JSON
.
stringify
(
err
)}
`
);
});
```
### stopInput<sup>(deprecated)</sup>
stopInput(callback: AsyncCallback
<
boolean
>
): void
结束输入会话。使用callback异步回调。
需要与编辑控件(如:输入框)绑定使用。当点击编辑控件后,才可通过调用该接口结束输入会话。
> **说明:**
>
> 从API version 6开始支持,从API version 9开始废弃,建议使用[stopInputSession()](#stopinputsession9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当输入法隐藏成功,err为undefined,data为true;否则为错误对象。 |
**示例:**
```
js
inputMethodController
.
stopInput
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to stopInput:
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
if
(
result
)
{
console
.
log
(
'
Succeeded in stopping input.
'
);
}
else
{
console
.
error
(
'
Failed to stopInput.
'
);
}
});
```
### stopInput<sup>(deprecated)</sup>
stopInput(): Promise
<
boolean
>
结束输入会话。使用promise异步回调。
需要与编辑控件(如:输入框)绑定使用。当点击编辑控件后,才可通过调用该接口结束输入会话。
> **说明:**
>
> 从API version 6开始支持,从API version 9开始废弃,建议使用[stopInputSession()](#stopinputsession9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
boolean
>
| Promise对象。返回true表示输入法隐藏成功;返回false表示输入法隐藏失败。 |
**示例:**
```
js
inputMethodController
.
stopInput
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
log
(
'
Succeeded in stopping input.
'
);
}
else
{
console
.
error
(
'
Failed to stopInput.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to stopInput:
${
JSON
.
stringify
(
err
)}
`
);
})
```
### on('insertText')<sup>10+</sup>
切换至指定输入法应用的指定子类型,用于跨输入法应用切换子类型。使用promise异步回调。
on(type: 'insertText', callback: (text: string) => void): void;
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用
。
订阅输入法应用插入文本事件。使用callback异步回调
。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
|inputMethodProperty |
[
InputMethodProperty
](
#inputmethodproperty8
)
| 是 | 传入要切换的目标输入法。 |
| type | string | 是 | 设置监听类型。
<br/>
- type为‘insertText’时表示订阅输入法应用插入文本事件监听。 |
|inputMethodSubtype |
[
InputMethodSubtype
](
./js-apis-inputmethod-subtype.md#inputmethodsubtype
)
| 是 | 传入要切换的目标输入法子类型。 |
| callback | (text: string) => void | 是 | 回调函数,返回需要插入的文本内容。
<br/>
开发者需要在回调函数中根据传入的文本内容操作编辑框中的内容。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------- | ---------------------------- |
| Promise
\<
boolean> | Promise对象。返回true表示切换至指定输入法应用的指定子类型成功;返回false表示切换至指定输入法应用的指定子类型失败。 |
**错误码:**
**错误码:**
...
@@ -439,94 +1644,118 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
...
@@ -439,94 +1644,118 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800009 | Input method client is detached. |
| 12800008 | Input method manager service error. |
**示例:**
**示例:**
```
js
```
js
let
im
=
inputMethod
.
getCurrentInputMethod
();
let
imSubType
=
inputMethod
.
getCurrentInputMethodSubtype
();
try
{
try
{
inputMethod
.
switchCurrentInputMethodAndSubtype
(
im
,
imSubType
).
then
((
result
)
=>
{
inputMethodController
.
on
(
'
insertText
'
,
(
text
)
=>
{
if
(
result
)
{
console
.
log
(
`Succeeded in subscribing insertText:
${
text
}
`
);
console
.
info
(
'
Succeeded in switching currentInputMethodAndSubtype.
'
);
});
}
else
{
console
.
error
(
'
Failed to switchCurrentInputMethodAndSubtype.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to switchCurrentInputMethodAndSubtype:
'
+
JSON
.
stringify
(
err
));
})
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to switchCurrentInputMethodAndSubtype:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to subscribe insertText:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
## inputMethod.getInputMethodController<sup>(deprecated)</sup>
### off('insertText')<sup>10+</sup>
getInputMethodController(): InputMethodController
获取客户端实例
[
InputMethodController
](
#inputmethodcontroller
)
。
off(type: 'insertText'): void
> **说明:**
取消订阅输入法应用插入文本事件。
>
> 从API version 6开始支持,从API version 9开始废弃, 建议使用[getController()](#inputmethodgetcontroller9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**
返回值
:**
**
参数
:**
|
类型 | 说明
|
|
参数名 | 类型 | 必填 | 说明
|
| ------
----------------------------------------- |
------------------------ |
| ------
| ------ | ---- | ------------------------------------
------------------------ |
|
[
InputMethodController
](
#inputmethodcontroller
)
| 回调返回当前客户端实例
。 |
|
type | string | 是 | 设置监听类型。
<br/>
- type为‘insertText’时表示取消订阅输入法应用插入文本事件监听
。 |
**示例:**
**示例:**
```
js
```
js
let
inputMethodController
=
inputMethod
.
getInputMethodController
(
);
inputMethodController
.
off
(
'
insertText
'
);
```
```
## inputMethod.getInputMethodSetting<sup>(deprecated)</sup>
### on('deleteLeft' | 'deleteRight')<sup>10+</sup>
getInputMethodSetting(): InputMethodSetting
获取客户端设置实例
[
InputMethodSetting
](
#inputmethodsetting8
)
。
on(type: 'deleteLeft' | 'deleteRight', callback: (length: number) => void): void
> **说明:**
订阅输入法应用向左删除或向右删除事件。使用callback异步回调。
>
> 从API version 6开始支持,从API version 9开始废弃, 建议使用[getSetting()](#inputmethodgetsetting9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**
返回值
:**
**
参数
:**
| 类型 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| ----------------------------------------- | ---------------------------- |
| -------- | ----- | ---- | ----- |
|
[
InputMethodSetting
](
#inputmethodsetting8
)
| 回调返回当前客户端设置实例。 |
| type | string | 是 | 设置监听类型。
<br/>
- type为‘deleteLeft’时表示订阅输入法应用向左删除事件监听。
<br/>
- type为‘deleteRight’时表示订阅输入法应用向右删除事件监听。|
| callback | (length: number) => void | 是 | 回调函数,返回需要向左或向右删除的文本的长度。
<br/>
开发者需要在回调函数中根据传入的删除长度操作编辑框中相应文本。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800009 | Input method client is detached. |
**示例:**
**示例:**
```
js
```
js
let
inputMethodSetting
=
inputMethod
.
getInputMethodSetting
();
try
{
inputMethodController
.
on
(
'
deleteLeft
'
,
(
length
)
=>
{
console
.
log
(
`Succeeded in subscribing deleteLeft, length:
${
length
}
`
);
});
}
catch
(
err
)
{
console
.
error
(
`Failed to subscribe deleteLeft:
${
JSON
.
stringify
(
err
)}
`
);
}
try
{
inputMethodController
.
on
(
'
deleteRight
'
,
(
length
)
=>
{
console
.
log
(
`Succeeded in subscribing deleteRight, length:
${
length
}
`
);
});
}
catch
(
err
)
{
console
.
error
(
`Failed to subscribe deleteRight:
${
JSON
.
stringify
(
err
)}
`
);
}
```
```
##
InputMethodController
##
# off('deleteLeft' | 'deleteRight')<sup>10+</sup>
下列API示例中都需使用
[
getController
](
#inputmethodgetcontroller9
)
获取到InputMethodController实例,再通过此实例调用对应方法。
off(type: 'deleteLeft' | 'deleteRight'): void
### stopInputSession<sup>9+</sup>
取消订阅输入法应用向左或向右删除文本事件。
stopInputSession(callback: AsyncCallback
<
boolean
>
): void
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
- type为‘deleteLeft’时表示取消订阅输入法应用向左删除的事件监听。
<br/>
- type为‘deleteRight’时表示取消订阅输入法应用向右删除的事件监听。|
**示例:**
结束输入会话。通过点击输入框实现输入会话的开启之后该接口的调用才可生效。使用callback异步回调。
```
js
inputMethodController
.
off
(
'
deleteLeft
'
);
inputMethodController
.
off
(
'
deleteRight
'
);
```
### on('sendKeyboardStatus')<sup>10+</sup>
on(type: 'sendKeyboardStatus', callback: (keyBoardStatus: KeyboardStatus) => void): void
订阅输入法应用发送键盘状态事件。使用callback异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | ------ | ---- | ---- |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当结束输入会话成功时,err为undefined,data为true;否则为错误对象。 |
| type | string | 是 | 设置监听类型。
<br/>
- type为‘sendKeyboardStatus’时表示订阅输入法应用发送键盘状态事件监听。 |
| callback | (keyBoardStatus:
[
KeyboardStatus
](
#keyboardstatus10
)
) => void | 是 | 回调函数,返回键盘状态。
<br/>
开发者需要在回调函数中根据传入的键盘状态做相应动作。 |
**错误码:**
**错误码:**
...
@@ -534,85 +1763,54 @@ stopInputSession(callback: AsyncCallback<boolean>): void
...
@@ -534,85 +1763,54 @@ stopInputSession(callback: AsyncCallback<boolean>): void
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800009 | Input method client is detached. |
| 12800008 | Input method manager service error. |
**示例:**
**示例:**
```
js
```
js
try
{
try
{
inputMethodController
.
stopInputSession
((
error
,
result
)
=>
{
inputMethodController
.
on
(
'
sendKeyboardStatus
'
,
(
keyBoardStatus
)
=>
{
if
(
error
!==
undefined
)
{
console
.
log
(
`Succeeded in subscribing sendKeyboardStatus, keyBoardStatus:
${
keyBoardStatus
}
`
);
console
.
error
(
'
Failed to stopInputSession:
'
+
JSON
.
stringify
(
error
));
return
;
}
if
(
result
)
{
console
.
info
(
'
Succeeded in stopping inputSession.
'
);
}
else
{
console
.
error
(
'
Failed to stopInputSession.
'
);
}
});
});
}
catch
(
err
or
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to stopInputSession:
'
+
JSON
.
stringify
(
error
)
);
console
.
error
(
`Failed to subscribe sendKeyboardStatus:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
###
stopInputSession<sup>9
+</sup>
###
off('sendKeyboardStatus')<sup>10
+</sup>
stopInputSession(): Promise
<
boolean
>
off(type: 'sendKeyboardStatus'): void
结束输入会话。通过点击输入框实现输入会话的开启之后此接口才可生效。使用promise异步回调
。
取消订阅输入法应用发送键盘状态事件
。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**返回值:**
**参数:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
boolean
>
| Promise对象。返回true表示结束输入会话成功;返回false表示结束输入会话失败。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| 12800003 | Input method client error. |
| type | string | 是 | 设置监听类型。
<br/>
- type为‘sendKeyboardStatus’时表示取消订阅输入法应用发送键盘状态事件监听。 |
| 12800008 | Input method manager service error. |
**示例:**
**示例:**
```
js
```
js
try
{
inputMethodController
.
off
(
'
sendKeyboardStatus
'
);
inputMethodController
.
stopInputSession
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Succeeded in stopping inputSession.
'
);
}
else
{
console
.
error
(
'
Failed to stopInputSession.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to stopInputSession:
'
+
JSON
.
stringify
(
err
));
})
}
catch
(
err
)
{
console
.
error
(
'
Failed to stopInputSession:
'
+
JSON
.
stringify
(
err
));
}
```
```
### showSoftKeyboard<sup>9+</sup>
### on('sendFunctionKey')<sup>10+</sup>
showSoftKeyboard(callback: AsyncCallback
<
void
>
): void
显示软键盘。需要与输入框绑定使用。当点击输入框后,才可通过该接口的调用显示出当前输入法的软键盘。使用callback异步回调。
on(type: 'sendFunctionKey', callback: (functionKey: FunctionKey) => void): void
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用
。
订阅输入法应用发送功能键事件。使用callback异步回调
。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------- |
| -------- | -------- | ---- | ----- |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当软键盘显示成功。err为undefined,否则为错误对象。 |
| type | string | 是 | 设置监听类型。
<br/>
- type为‘sendFunctionKey’时表示订阅输入法应用发送功能键事件监听。 |
| callback | (functionKey:
[
FunctionKey
](
#functionkey10
)
) => void | 是 | 回调函数,返回输入法应用发送的功能键信息。
<br/>
开发者需要根据返回的功能键做相应的操作。 |
**错误码:**
**错误码:**
...
@@ -620,192 +1818,148 @@ showSoftKeyboard(callback: AsyncCallback<void>): void
...
@@ -620,192 +1818,148 @@ showSoftKeyboard(callback: AsyncCallback<void>): void
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800009 | Input method client is detached. |
| 12800008 | Input method manager service error. |
**示例:**
**示例:**
```
js
```
js
inputMethodController
.
showSoftKeyboard
((
err
)
=>
{
try
{
if
(
err
===
undefined
)
{
inputMethodController
.
on
(
'
sendFunctionKey
'
,
(
functionKey
)
=>
{
console
.
info
(
'
Succeeded in showing softKeyboard.
'
);
console
.
log
(
`Succeeded in subscribing sendFunctionKey, functionKey.enterKeyType:
${
functionKey
.
enterKeyType
}
`
);
}
else
{
});
console
.
error
(
'
Failed to showSoftKeyboard:
'
+
JSON
.
stringify
(
err
));
}
catch
(
err
)
{
}
console
.
error
(
`Failed to subscribe sendFunctionKey:
${
JSON
.
stringify
(
err
)}
`
);
}
)
}
```
```
### showSoftKeyboard<sup>9+</sup>
### off('sendFunctionKey')<sup>10+</sup>
showSoftKeyboard(): Promise
<
void
>
显示软键盘。需要与输入框绑定使用。当点击输入框后,才可通过该接口的调用显示出当前输入法的软键盘。使用Promise异步回调。
off(type: 'sendFunctionKey'): void
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用
。
取消订阅输入法应用发送FunctionKey事件
。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**返回值:**
**参数:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| 12800003 | Input method client error. |
| type | string | 是 | 设置监听类型。
<br/>
- type为‘sendFunctionKey’时表示取消订阅输入法应用发送FunctionKey事件监听。 |
| 12800008 | Input method manager service error. |
**示例:**
**示例:**
```
js
```
js
inputMethodController
.
showSoftKeyboard
().
then
(()
=>
{
inputMethodController
.
off
(
'
sendFunctionKey
'
);
console
.
log
(
'
Succeeded in showing softKeyboard.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to showSoftKeyboard:
'
+
JSON
.
stringify
(
err
));
});
```
```
### hideSoftKeyboard<sup>9+</sup>
### on('moveCursor')<sup>10+</sup>
hideSoftKeyboard(callback: AsyncCallback
<
void
>
): void
隐藏软键盘。需要与输入框绑定使用。点击输入框后,才可以使用该接口的调用隐藏软键盘。使用callback异步回调。
on(type: 'moveCursor', callback: (direction: Direction) => void): void
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用
。
订阅输入法应用移动光标事件。使用callback异步回调
。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------- |
| -------- | ------ | ---- | ------ |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当软键盘隐藏成功。err为undefined,否则为错误对象。 |
| type | string | 是 | 设置监听类型。
<br/>
- type为‘moveCursor’时表示订阅输入法应用移动光标事件监听。 |
| callback | callback: (direction:
[
Direction<sup>10+</sup>
](
#direction10
)
) => void | 是 | 回调函数,返回光标信息。
<br/>
开发者需要根据返回的光标移动方向改变光标位置。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| -------- | -------------------------------- |
| 12800003 | Input method client error. |
| 12800009 | Input method client is detached. |
| 12800008 | Input method manager service error. |
**示例:**
**示例:**
```
js
```
js
inputMethodController
.
hideSoftKeyboard
((
err
)
=>
{
try
{
if
(
err
===
undefined
)
{
inputMethodController
.
on
(
'
moveCursor
'
,
(
direction
)
=>
{
console
.
info
(
'
Succeeded in hiding softKeyboard.
'
);
console
.
log
(
`Succeeded in subscribing moveCursor, direction:
${
direction
}
`
);
}
else
{
});
console
.
error
(
'
Failed to hideSoftKeyboard:
'
+
JSON
.
stringify
(
err
));
}
catch
(
err
)
{
}
console
.
error
(
`Failed to subscribe moveCursor:
${
JSON
.
stringify
(
err
)}
`
);
}
)
}
```
```
### hideSoftKeyboard<sup>9+</sup>
### off('moveCursor')<sup>10+</sup>
hideSoftKeyboard(): Promise
<
void
>
隐藏软键盘。需要与输入框绑定使用。点击输入框后,才可以使用该接口的调用隐藏软键盘。使用Promise异步回调。
off(type: 'moveCursor'): void
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用
。
取消订阅输入法应用移动光标事件
。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**返回值:**
**参数:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- |
| ------ | ------ | ---- | ---- |
| 12800003 | Input method client error. |
| type | string | 是 | 设置监听类型。
<br/>
- type为‘moveCursor’时表示取消订阅输入法应用发送移动光标事件监听。 |
| 12800008 | Input method manager service error. |
**示例:**
**示例:**
```
js
```
js
inputMethodController
.
hideSoftKeyboard
().
then
(()
=>
{
inputMethodController
.
off
(
'
moveCursor
'
);
console
.
log
(
'
Succeeded in hiding softKeyboard.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to hideSoftKeyboard:
'
+
JSON
.
stringify
(
err
));
});
```
```
### stopInput<sup>(deprecated)</sup>
### on('handleExtendAction')<sup>10+</sup>
stopInput(callback: AsyncCallback
<
boolean
>
): void
结束输入会话。通过点击输入框实现输入会话的开启之后该接口的调用才可生效。使用callback异步回调。
on(type: 'handleExtendAction', callback: (action: ExtendAction) => void): void
> **说明:**
订阅输入法应用发送扩展操作事件。使用callback异步回调。
>
> 从API version 6开始支持,从API version 9开始废弃, 建议使用[stopInputSession()](#stopinputsession9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | ------ | ---- | -------- |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当输入法隐藏成功,err为undefined,data为true;否则为错误对象。 |
| type | string | 是 | 设置监听类型。
<br/>
- type为‘handleExtendAction’时表示订阅输入法应用发送扩展操作代码事件监听。 |
| callback | callback: (action:
[
ExtendAction
](
#extendaction10
)
) => void | 是 | 回调函数,返回扩展操作类型。
<br/>
开发者需要在回调函数中根据传入的扩展操作类型做相应的操作。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800009 | Input method client is detached. |
**示例:**
**示例:**
```
js
```
js
inputMethodController
.
stopInput
((
error
,
result
)
=>
{
try
{
if
(
error
!==
undefined
)
{
inputMethodController
.
on
(
'
handleExtendAction
'
,
(
action
)
=>
{
console
.
error
(
'
Failed to stopInput:
'
+
JSON
.
stringify
(
error
));
console
.
log
(
`Succeeded in subscribing handleExtendAction, action:
${
action
}
`
);
return
;
});
}
}
catch
(
err
)
{
if
(
result
)
{
console
.
error
(
`Failed to subscribe handleExtendAction:
${
JSON
.
stringify
(
err
)}
`
);
console
.
info
(
'
Succeeded in stopping input.
'
);
}
}
else
{
console
.
error
(
'
Failed to stopInput.
'
);
}
});
```
```
### stopInput<sup>(deprecated)</sup>
### off('handleExtendAction')<sup>10+</sup>
stopInput(): Promise
<
boolean
>
结束输入会话。通过点击输入框实现输入会话的开启之后该接口的调用才可生效。使用promise异步回调。
off(type: 'handleExtendAction'): void
> **说明:**
取消订阅输入法应用发送扩展操作事件。
>
> 从API version 6开始支持,从API version 9开始废弃, 建议使用[stopInputSession()](#stopinputsession9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**
返回值
:**
**
参数
:**
|
类型 | 说明
|
|
参数名 | 类型 | 必填 | 说明
|
| ------
-- | -
------- |
| ------
| ------ | ---- |
------- |
|
Promise
<
boolean
>
| Promise对象。返回true表示输入法隐藏成功;返回false表示输入法隐藏失败
。 |
|
type | string | 是 | 设置监听类型。
<br/>
- type为‘handleExtendAction’时表示取消订阅输入法应用发送扩展代码事件监听
。 |
**示例:**
**示例:**
```
js
```
js
inputMethodController
.
stopInput
().
then
((
result
)
=>
{
inputMethodController
.
off
(
'
handleExtendAction
'
);
if
(
result
)
{
console
.
info
(
'
Succeeded in stopping input.
'
);
}
else
{
console
.
error
(
'
Failed to stopInput.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to stopInput:
'
+
err
);
})
```
```
### on('selectByRange')<sup>10+</sup>
### on('selectByRange')<sup>10+</sup>
...
@@ -819,15 +1973,15 @@ on(type: 'selectByRange', callback: Callback<Range>): void
...
@@ -819,15 +1973,15 @@ on(type: 'selectByRange', callback: Callback<Range>): void
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----
-------------------------------------------------------- | ---- | -----------------------------------------------------
------- |
| -------- | ----
| ---- |
------- |
| type | string
| 是 | 设置监听类型。
<br/>
-
type为‘selectByRange’时表示订阅输入法应用按范围选中文本事件监听。 |
| type | string
| 是 | 设置监听类型。
<br/>
-
type为‘selectByRange’时表示订阅输入法应用按范围选中文本事件监听。 |
| callback | Callback
<
[Range](
./js-apis-inputmethod-InputMethodCommon.md#range
)
>
| 是 | 回调函数,返回需要选中的文本的范围。
<br/>
开发者需要在回调函数中根据传入的范围选中编辑框中相应文本。 |
| callback | Callback
<
[Range](
#range10
)
>
| 是 | 回调函数,返回需要选中的文本的范围。
<br/>
开发者需要在回调函数中根据传入的范围选中编辑框中相应文本。 |
**示例:**
**示例:**
```
js
```
js
inputMethodController
.
on
(
'
selectByRange
'
,
(
range
)
=>
{
inputMethodController
.
on
(
'
selectByRange
'
,
(
range
)
=>
{
console
.
info
(
'
Succeeded in subscribing selectByRange: start:
'
+
range
.
start
+
"
, end:
"
+
range
.
end
);
console
.
log
(
`Succeeded in subscribing selectByRange: start:
${
range
.
start
}
, end:
${
range
.
end
}
`
);
});
});
```
```
...
@@ -843,7 +1997,7 @@ off(type: 'selectByRange'): void
...
@@ -843,7 +1997,7 @@ off(type: 'selectByRange'): void
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
-type为‘selectByRange’时表示取消订阅输入法应用按范围选中文本事件监听。 |
| type | string | 是 | 设置监听类型。
<br/>
-
type为‘selectByRange’时表示取消订阅输入法应用按范围选中文本事件监听。 |
**示例:**
**示例:**
...
@@ -862,15 +2016,15 @@ on(type: 'selectByMovement', callback: Callback<Movement>): void
...
@@ -862,15 +2016,15 @@ on(type: 'selectByMovement', callback: Callback<Movement>): void
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -----
------------------------------------------------------- | ---- | ------------------------------------------------------
------ |
| -------- | -----
| ---- |
------ |
| type | string
| 是 | 设置监听类型。
<br/>
-
type为‘selectByMovement’时表示订阅输入法应用按光标移动动作选中文本事件监听。 |
| type | string
| 是 | 设置监听类型。
<br/>
-
type为‘selectByMovement’时表示订阅输入法应用按光标移动动作选中文本事件监听。 |
| callback | Callback
<
[Movement](
./js-apis-inputmethod-InputMethodCommon.md#movement
)
>
| 是 | 回调函数,返回需要选中的文本的范围。
<br/>
开发者需要在回调函数中根据传入的光标动作选中编辑框中相应文本。 |
| callback | Callback
<
[Movement](
#movement10
)
>
| 是 | 回调函数,返回需要选中的文本的范围。
<br/>
开发者需要在回调函数中根据传入的光标动作选中编辑框中相应文本。 |
**示例:**
**示例:**
```
js
```
js
inputMethodController
.
on
(
'
selectByMovement
'
,
(
movement
)
=>
{
inputMethodController
.
on
(
'
selectByMovement
'
,
(
movement
)
=>
{
console
.
info
(
'
Succeeded in subscribing selectByMovement: direction:
'
+
movement
.
direction
);
console
.
log
(
'
Succeeded in subscribing selectByMovement: direction:
'
+
movement
.
direction
);
});
});
```
```
...
@@ -886,7 +2040,7 @@ off(type: 'selectByMovement'): void
...
@@ -886,7 +2040,7 @@ off(type: 'selectByMovement'): void
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
-type为‘selectByMovement’时表示取消订阅输入法应用按范围选中文本事件监听。 |
| type | string | 是 | 设置监听类型。
<br/>
-
type为‘selectByMovement’时表示取消订阅输入法应用按范围选中文本事件监听。 |
**示例:**
**示例:**
...
@@ -910,14 +2064,14 @@ on(type: 'imeChange', callback: (inputMethodProperty: InputMethodProperty, input
...
@@ -910,14 +2064,14 @@ on(type: 'imeChange', callback: (inputMethodProperty: InputMethodProperty, input
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
-type为‘imeChange’时表示订阅输入法及子类型变化监听事件。 |
| type | string | 是 | 设置监听类型。
<br/>
-
type为‘imeChange’时表示订阅输入法及子类型变化监听事件。 |
| callback | (inputMethodProperty:
[
InputMethodProperty
](
#inputmethodproperty8
)
, inputMethodSubtype:
[
InputMethodSubtype
](
./js-apis-inputmethod-subtype.md#inputmethodsubtype
)
) => void | 是 | 回调函数,返回输入法属性对象及输入法子类型对象。 |
| callback | (inputMethodProperty:
[
InputMethodProperty
](
#inputmethodproperty8
)
, inputMethodSubtype:
[
InputMethodSubtype
](
./js-apis-inputmethod-subtype.md#inputmethodsubtype
)
) => void | 是 | 回调函数,返回输入法属性对象及输入法子类型对象。 |
**示例:**
**示例:**
```
js
```
js
inputMethodSetting
.
on
(
'
imeChange
'
,
(
inputMethodProperty
,
inputMethodSubtype
)
=>
{
inputMethodSetting
.
on
(
'
imeChange
'
,
(
inputMethodProperty
,
inputMethodSubtype
)
=>
{
console
.
info
(
'
Succeeded in subscribing imeChange: inputMethodProperty:
'
+
JSON
.
stringify
(
inputMethodProperty
)
+
"
, inputMethodSubtype:
"
+
JSON
.
stringify
(
inputMethodSubtype
));
console
.
log
(
'
Succeeded in subscribing imeChange: inputMethodProperty:
'
+
JSON
.
stringify
(
inputMethodProperty
)
+
"
, inputMethodSubtype:
"
+
JSON
.
stringify
(
inputMethodSubtype
));
});
});
```
```
...
@@ -932,8 +2086,8 @@ off(type: 'imeChange', callback?: (inputMethodProperty: InputMethodProperty, inp
...
@@ -932,8 +2086,8 @@ off(type: 'imeChange', callback?: (inputMethodProperty: InputMethodProperty, inp
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------
---------------------- | ---- | ---------------------------------------------
--------------- |
| -------- | ---------
| ---- |
--------------- |
| type | string
| 是 | 设置监听类型。
<br/>
-
type为‘imeChange’时表示取消订阅输入法及子类型变化监听事件。 |
| type | string
| 是 | 设置监听类型。
<br/>
-
type为‘imeChange’时表示取消订阅输入法及子类型变化监听事件。 |
| callback | (inputMethodProperty:
[
InputMethodProperty
](
#inputmethodproperty8
)
, inputMethodSubtype:
[
InputMethodSubtype
](
./js-apis-inputmethod-subtype.md#inputmethodsubtype
)
) => void | 否 | 回调函数,返回取消订阅的输入法属性对象及输入法子类型对象。 |
| callback | (inputMethodProperty:
[
InputMethodProperty
](
#inputmethodproperty8
)
, inputMethodSubtype:
[
InputMethodSubtype
](
./js-apis-inputmethod-subtype.md#inputmethodsubtype
)
) => void | 否 | 回调函数,返回取消订阅的输入法属性对象及输入法子类型对象。 |
**示例:**
**示例:**
...
@@ -954,7 +2108,7 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async
...
@@ -954,7 +2108,7 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------------- | ---- | ---------------------- |
| -------- | -------------------------------------------------- | ---- | ---------------------- |
| inputMethodProperty |
InputMethodProperty
| 是 | 子类型所属的输入法应用。 |
| inputMethodProperty |
[
InputMethodProperty
](
#inputmethodproperty8
)
| 是 | 子类型所属的输入法应用。 |
| callback | AsyncCallback
<
Array
<
[
InputMethodSubtype
](./
js-apis-inputmethod-subtype.md#inputmethodsubtype
)
>
>
| 是 | 回调函数,返回指定输入法应用的所有子类型。 |
| callback | AsyncCallback
<
Array
<
[
InputMethodSubtype
](./
js-apis-inputmethod-subtype.md#inputmethodsubtype
)
>
>
| 是 | 回调函数,返回指定输入法应用的所有子类型。 |
**错误码:**
**错误码:**
...
@@ -970,22 +2124,19 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async
...
@@ -970,22 +2124,19 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async
```
js
```
js
let
inputMethodProperty
=
{
let
inputMethodProperty
=
{
packageName
:
'
com.example.kikakeyboard
'
,
methodId
:
'
com.example.kikakeyboard
'
,
name
:
'
com.example.kikakeyboard
'
,
name
:
'
com.example.kikakeyboard
'
,
id
:
'
com.example.kikakeyboard
'
,
id
:
'
propertyId
'
,
extra
:{}
}
}
try
{
try
{
inputMethodSetting
.
listInputMethodSubtype
(
inputMethodProperty
,
(
err
,
data
)
=>
{
inputMethodSetting
.
listInputMethodSubtype
(
inputMethodProperty
,
(
err
,
data
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to listInputMethodSubtype:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to listInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
log
(
'
Succeeded in listing inputMethodSubtype.
'
);
console
.
log
(
'
Succeeded in listing inputMethodSubtype.
'
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to listInputMethodSubtype:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to listInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1001,7 +2152,7 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise<Arr
...
@@ -1001,7 +2152,7 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise<Arr
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------------- | ---- | ---------------------- |
| -------- | -------------------------------------------------- | ---- | ---------------------- |
| inputMethodProperty |
InputMethodProperty
| 是 | 子类型所属的输入法应用。 |
| inputMethodProperty |
[
InputMethodProperty
](
#inputmethodproperty8
)
| 是 | 子类型所属的输入法应用。 |
**返回值:**
**返回值:**
...
@@ -1022,20 +2173,17 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise<Arr
...
@@ -1022,20 +2173,17 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise<Arr
```
js
```
js
let
inputMethodProperty
=
{
let
inputMethodProperty
=
{
packageName
:
'
com.example.kikakeyboard
'
,
methodId
:
'
com.example.kikakeyboard
'
,
name
:
'
com.example.kikakeyboard
'
,
name
:
'
com.example.kikakeyboard
'
,
id
:
'
com.example.kikakeyboard
'
,
id
:
'
propertyId
'
,
extra
:{}
}
}
try
{
try
{
inputMethodSetting
.
listInputMethodSubtype
(
inputMethodProperty
).
then
((
data
)
=>
{
inputMethodSetting
.
listInputMethodSubtype
(
inputMethodProperty
).
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in listing inputMethodSubtype.
'
);
console
.
log
(
'
Succeeded in listing inputMethodSubtype.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to listInputMethodSubtype:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to listInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to listInputMethodSubtype:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to listInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1067,14 +2215,14 @@ listCurrentInputMethodSubtype(callback: AsyncCallback<Array<InputMethodSub
...
@@ -1067,14 +2215,14 @@ listCurrentInputMethodSubtype(callback: AsyncCallback<Array<InputMethodSub
```
js
```
js
try
{
try
{
inputMethodSetting
.
listCurrentInputMethodSubtype
((
err
,
data
)
=>
{
inputMethodSetting
.
listCurrentInputMethodSubtype
((
err
,
data
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to listCurrentInputMethodSubtype:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to listCurrentInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
log
(
'
Succeeded in listing currentInputMethodSubtype.
'
);
console
.
log
(
'
Succeeded in listing currentInputMethodSubtype.
'
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to listCurrentInputMethodSubtype:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to listCurrentInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1106,12 +2254,12 @@ listCurrentInputMethodSubtype(): Promise<Array<InputMethodSubtype>>
...
@@ -1106,12 +2254,12 @@ listCurrentInputMethodSubtype(): Promise<Array<InputMethodSubtype>>
```
js
```
js
try
{
try
{
inputMethodSetting
.
listCurrentInputMethodSubtype
().
then
((
data
)
=>
{
inputMethodSetting
.
listCurrentInputMethodSubtype
().
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in listing currentInputMethodSubtype.
'
);
console
.
log
(
'
Succeeded in listing currentInputMethodSubtype.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to listCurrentInputMethodSubtype:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to listCurrentInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to listCurrentInputMethodSubtype:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to listCurrentInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1119,7 +2267,9 @@ try {
...
@@ -1119,7 +2267,9 @@ try {
getInputMethods(enable: boolean, callback: AsyncCallback
<
Array
<
InputMethodProperty
>>
): void
getInputMethods(enable: boolean, callback: AsyncCallback
<
Array
<
InputMethodProperty
>>
): void
获取已激活/未激活输入法列表。参数enable取true,返回已激活输入法列表,取false返回未激活输入法列表。已激活/未激活输入法的确切功能当前版本未支持。当前版本中,已激活输入法包括当前使用的输入法,未激活输入法包括当前输入法以外的其他已安装的输入法。使用callback异步回调。
获取已激活/未激活输入法列表。使用callback异步回调。
参数enable取true,返回已激活输入法列表;取false返回未激活输入法列表。已激活/未激活为预留概念,当前暂未支持。当前版本中,已激活输入法包括当前使用的输入法,未激活输入法包括当前输入法以外的其他已安装的输入法。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -1143,15 +2293,15 @@ getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethod
...
@@ -1143,15 +2293,15 @@ getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethod
```
js
```
js
try
{
try
{
inputMethodSetting
.
getInputMethods
(
true
,
(
err
,
data
)
=>
{
inputMethodSetting
.
getInputMethods
(
true
,
(
err
,
data
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to getInputMethods:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getInputMethods:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
log
(
'
Succeeded in getting inputMethods.
'
);
console
.
log
(
'
Succeeded in getting inputMethods.
'
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to getInputMethods:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getInputMethods:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1159,7 +2309,9 @@ try {
...
@@ -1159,7 +2309,9 @@ try {
getInputMethods(enable: boolean): Promise
<
Array
<
InputMethodProperty
>>
getInputMethods(enable: boolean): Promise
<
Array
<
InputMethodProperty
>>
获取已激活/未激活输入法列表。参数enable取true,返回已激活输入法列表,取false返回未激活输入法列表。已激活/未激活输入法的确切功能当前版本未支持。当前版本中,已激活输入法包括当前使用的输入法,未激活输入法包括当前输入法以外的其他已安装的输入法。使用promise异步回调。
获取已激活/未激活输入法列表。使用promise异步回调。
参数enable取true,返回已激活输入法列表;取false返回未激活输入法列表。已激活/未激活为预留概念,当前暂未支持。当前版本中,已激活输入法包括当前使用的输入法,未激活输入法包括当前输入法以外的其他已安装的输入法。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -1189,12 +2341,12 @@ getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>>
...
@@ -1189,12 +2341,12 @@ getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>>
```
js
```
js
try
{
try
{
inputMethodSetting
.
getInputMethods
(
true
).
then
((
data
)
=>
{
inputMethodSetting
.
getInputMethods
(
true
).
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in getting inputMethods.
'
);
console
.
log
(
'
Succeeded in getting inputMethods.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to getInputMethods:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getInputMethods:
${
JSON
.
stringify
(
err
)}
`
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to getInputMethods:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getInputMethods:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1225,14 +2377,14 @@ showOptionalInputMethods(callback: AsyncCallback<boolean>): void
...
@@ -1225,14 +2377,14 @@ showOptionalInputMethods(callback: AsyncCallback<boolean>): void
```
js
```
js
try
{
try
{
inputMethodSetting
.
showOptionalInputMethods
((
err
,
data
)
=>
{
inputMethodSetting
.
showOptionalInputMethods
((
err
,
data
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to showOptionalInputMethods:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to showOptionalInputMethods:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
info
(
'
Succeeded in showing optionalInputMethods.
'
);
console
.
log
(
'
Succeeded in showing optionalInputMethods.
'
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to showOptionalInputMethods:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to showOptionalInputMethods:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1262,9 +2414,9 @@ showOptionalInputMethods(): Promise<boolean>
...
@@ -1262,9 +2414,9 @@ showOptionalInputMethods(): Promise<boolean>
```
js
```
js
inputMethodSetting
.
showOptionalInputMethods
().
then
((
data
)
=>
{
inputMethodSetting
.
showOptionalInputMethods
().
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in showing optionalInputMethods.
'
);
console
.
log
(
'
Succeeded in showing optionalInputMethods.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to showOptionalInputMethods:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to showOptionalInputMethods:
${
JSON
.
stringify
(
err
)}
`
);
})
})
```
```
...
@@ -1276,7 +2428,7 @@ listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>)
...
@@ -1276,7 +2428,7 @@ listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>)
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,从API version 9开始废弃
,
建议使用[getInputMethods](#getinputmethods9)替代。
> 从API version 8开始支持,从API version 9开始废弃
,
建议使用[getInputMethods](#getinputmethods9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -1289,9 +2441,9 @@ listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>)
...
@@ -1289,9 +2441,9 @@ listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>)
**示例:**
**示例:**
```
js
```
js
inputMethodSetting
.
listInputMethod
((
err
,
data
)
=>
{
inputMethodSetting
.
listInputMethod
((
err
,
data
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to listInputMethod:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to listInputMethod:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
log
(
'
Succeeded in listing inputMethod.
'
);
console
.
log
(
'
Succeeded in listing inputMethod.
'
);
...
@@ -1306,7 +2458,7 @@ listInputMethod(): Promise<Array<InputMethodProperty>>
...
@@ -1306,7 +2458,7 @@ listInputMethod(): Promise<Array<InputMethodProperty>>
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,从API version 9开始废弃
,
建议使用[getInputMethods](#getinputmethods9-1)替代。
> 从API version 8开始支持,从API version 9开始废弃
,
建议使用[getInputMethods](#getinputmethods9-1)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -1320,9 +2472,9 @@ listInputMethod(): Promise<Array<InputMethodProperty>>
...
@@ -1320,9 +2472,9 @@ listInputMethod(): Promise<Array<InputMethodProperty>>
```
js
```
js
inputMethodSetting
.
listInputMethod
().
then
((
data
)
=>
{
inputMethodSetting
.
listInputMethod
().
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in listing inputMethod.
'
);
console
.
log
(
'
Succeeded in listing inputMethod.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to listInputMethod:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to listInputMethod:
${
JSON
.
stringify
(
err
)}
`
);
})
})
```
```
...
@@ -1334,7 +2486,7 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void
...
@@ -1334,7 +2486,7 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,从API version 9开始废弃
,
建议使用[showOptionalInputMethods()](#showoptionalinputmethods9)替代。
> 从API version 8开始支持,从API version 9开始废弃
,
建议使用[showOptionalInputMethods()](#showoptionalinputmethods9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -1348,11 +2500,11 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void
...
@@ -1348,11 +2500,11 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void
```
js
```
js
inputMethodSetting
.
displayOptionalInputMethod
((
err
)
=>
{
inputMethodSetting
.
displayOptionalInputMethod
((
err
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to displayOptionalInputMethod:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to displayOptionalInputMethod:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
info
(
'
Succeeded in displaying optionalInputMethod.
'
);
console
.
log
(
'
Succeeded in displaying optionalInputMethod.
'
);
});
});
```
```
...
@@ -1364,7 +2516,7 @@ displayOptionalInputMethod(): Promise<void>
...
@@ -1364,7 +2516,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
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -1378,8 +2530,8 @@ displayOptionalInputMethod(): Promise<void>
...
@@ -1378,8 +2530,8 @@ displayOptionalInputMethod(): Promise<void>
```
js
```
js
inputMethodSetting
.
displayOptionalInputMethod
().
then
(()
=>
{
inputMethodSetting
.
displayOptionalInputMethod
().
then
(()
=>
{
console
.
info
(
'
Succeeded in displaying optionalInputMethod.
'
);
console
.
log
(
'
Succeeded in displaying optionalInputMethod.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to displayOptionalInputMethod:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to displayOptionalInputMethod:
${
JSON
.
stringify
(
err
)}
`
);
})
})
```
```
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
浏览文件 @
af32ae67
...
@@ -56,7 +56,9 @@ import inputMethodEngine from '@ohos.inputMethodEngine';
...
@@ -56,7 +56,9 @@ import inputMethodEngine from '@ohos.inputMethodEngine';
getInputMethodAbility(): InputMethodAbility
getInputMethodAbility(): InputMethodAbility
为输入法应用获取输入法应用客户端实例
[
InputMethodAbility
](
#inputmethodability
)
。输入法应用获取该实例可订阅软键盘显示/隐藏请求事件、创建/销毁输入法应用面板等。
为输入法应用获取输入法应用客户端实例
[
InputMethodAbility
](
#inputmethodability
)
。
该接口仅限于输入法应用调用。
输入法应用获取该实例可订阅软键盘显示/隐藏请求事件、创建/销毁输入法应用面板等。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -100,7 +102,7 @@ getInputMethodEngine(): InputMethodEngine
...
@@ -100,7 +102,7 @@ getInputMethodEngine(): InputMethodEngine
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[getInputMethodAbility()](#inputmethodenginegetinputmethodability9)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[getInputMethodAbility()](#inputmethodenginegetinputmethodability9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -124,7 +126,7 @@ createKeyboardDelegate(): KeyboardDelegate
...
@@ -124,7 +126,7 @@ createKeyboardDelegate(): KeyboardDelegate
> **说明:**
> **说明:**
>
>
>从API version 8开始支持,API version 9开始废弃
,
建议使用[getKeyboardDelegate()](#inputmethodenginegetkeyboarddelegate9)替代。
>从API version 8开始支持,API version 9开始废弃
,
建议使用[getKeyboardDelegate()](#inputmethodenginegetkeyboarddelegate9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -443,7 +445,7 @@ on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => voi
...
@@ -443,7 +445,7 @@ on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => voi
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---
--------------------------------------------------------- | ---- | ---------------------------------------------------------
--- |
| -------- | ---
| ---- |
--- |
| type | string | 是 | 设置监听类型。
<br/>
-
type为'setSubtype',表示订阅输入法子类型的设置事件。 |
| type | string | 是 | 设置监听类型。
<br/>
-
type为'setSubtype',表示订阅输入法子类型的设置事件。 |
| callback | (inputMethodSubtype:
[
InputMethodSubtype
](
js-apis-inputmethod-subtype.md
)
) => void | 是 | 回调函数,返回设置的输入法子类型。 |
| callback | (inputMethodSubtype:
[
InputMethodSubtype
](
js-apis-inputmethod-subtype.md
)
) => void | 是 | 回调函数,返回设置的输入法子类型。 |
...
@@ -466,7 +468,7 @@ off(type: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => v
...
@@ -466,7 +468,7 @@ off(type: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => v
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------
- | ------------------------------------------------------------ | ---- | --------------------------------------------------------
---- |
| -------
| ----- | ---- |
---- |
| type | string | 是 | 设置监听类型。
<br/>
-
type为'setSubtype',表示取消订阅输入法子类型的设置事件。 |
| type | string | 是 | 设置监听类型。
<br/>
-
type为'setSubtype',表示取消订阅输入法子类型的设置事件。 |
| callback | (inputMethodSubtype:
[
InputMethodSubtype
](
js-apis-inputmethod-subtype.md
)
) => void | 否 | 回调函数,返回设置的输入法子类型。 |
| callback | (inputMethodSubtype:
[
InputMethodSubtype
](
js-apis-inputmethod-subtype.md
)
) => void | 否 | 回调函数,返回设置的输入法子类型。 |
...
@@ -482,7 +484,9 @@ inputMethodEngine.getInputMethodAbility().off('setSubtype', () => {
...
@@ -482,7 +484,9 @@ inputMethodEngine.getInputMethodAbility().off('setSubtype', () => {
createPanel(ctx: BaseContext, info: PanelInfo, callback: AsyncCallback
\<
Panel>): void
createPanel(ctx: BaseContext, info: PanelInfo, callback: AsyncCallback
\<
Panel>): void
创建输入法应用面板。仅支持输入法应用或者具有system_core权限的系统应用调用。单个输入法应用仅仅允许创建一个SOFT_KEYBOARD及一个STATUS_BAR类型的面板。使用callback异步回调。
创建输入法应用面板。使用callback异步回调。
仅支持输入法应用调用。单个输入法应用仅仅允许创建一个SOFT_KEYBOARD及一个STATUS_BAR类型的面板。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -504,19 +508,19 @@ createPanel(ctx: BaseContext, info: PanelInfo, callback: AsyncCallback\<Panel>):
...
@@ -504,19 +508,19 @@ createPanel(ctx: BaseContext, info: PanelInfo, callback: AsyncCallback\<Panel>):
```
js
```
js
let
panelInfo
:
inputMethodEngine
.
PanelInfo
=
{
let
panelInfo
:
inputMethodEngine
.
PanelInfo
=
{
panelType
:
SOFT_KEYBOARD
,
panelType
:
inputMethodEngine
.
PanelType
.
SOFT_KEYBOARD
,
panelFlag
:
FLG_FIXED
panelFlag
:
inputMethodEngine
.
PanelFlag
.
FLG_FIXED
}
}
try
{
try
{
inputMethodEngine
.
getInputMethodAbility
().
createPanel
(
this
.
context
,
panelInfo
,
(
err
,
panel
)
=>
{
inputMethodEngine
.
getInputMethodAbility
().
createPanel
(
this
.
context
,
panelInfo
,
(
err
,
panel
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
log
(
'
Failed to create panel, err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to createPanel:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
log
(
'
Succeed in creating panel.
'
);
console
.
log
(
'
Succeed in creating panel.
'
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
'
Failed to create panel, err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to createPanel:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -524,7 +528,9 @@ try {
...
@@ -524,7 +528,9 @@ try {
createPanel(ctx: BaseContext, info: PanelInfo): Promise
\<
Panel>
createPanel(ctx: BaseContext, info: PanelInfo): Promise
\<
Panel>
创建输入法应用面板。仅支持输入法应用或者具有system_core权限的系统应用调用。单个输入法应用仅仅允许创建一个SOFT_KEYBOARD及一个STATUS_BAR类型的面板。使用promise异步回调。
创建输入法应用面板。使用promise异步回调。
仅支持输入法应用调用。单个输入法应用仅仅允许创建一个SOFT_KEYBOARD及一个STATUS_BAR类型的面板。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -550,13 +556,13 @@ createPanel(ctx: BaseContext, info: PanelInfo): Promise\<Panel>
...
@@ -550,13 +556,13 @@ createPanel(ctx: BaseContext, info: PanelInfo): Promise\<Panel>
```
js
```
js
let
panelInfo
:
inputMethodEngine
.
PanelInfo
=
{
let
panelInfo
:
inputMethodEngine
.
PanelInfo
=
{
panelType
:
SOFT_KEYBOARD
,
panelType
:
inputMethodEngine
.
PanelType
.
SOFT_KEYBOARD
,
panelFlag
:
FLG_FIXED
panelFlag
:
inputMethodEngine
.
PanelFlag
.
FLG_FIXED
}
}
inputMethodEngine
.
getInputMethodAbility
().
createPanel
(
this
.
context
,
panelInfo
).
then
((
panel
)
=>
{
inputMethodEngine
.
getInputMethodAbility
().
createPanel
(
this
.
context
,
panelInfo
).
then
((
panel
)
=>
{
console
.
log
(
'
Succeed in creating panel.
'
);
console
.
log
(
'
Succeed in creating panel.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
log
(
'
Failed to create panel, err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to create panel:
${
JSON
.
stringify
(
err
)}
`
);
})
})
```
```
...
@@ -579,32 +585,32 @@ destroyPanel(panel: Panel, callback: AsyncCallback\<void>): void;
...
@@ -579,32 +585,32 @@ destroyPanel(panel: Panel, callback: AsyncCallback\<void>): void;
```
js
```
js
let
panelInfo
:
inputMethodEngine
.
PanelInfo
=
{
let
panelInfo
:
inputMethodEngine
.
PanelInfo
=
{
panelType
:
SOFT_KEYBOARD
,
panelType
:
inputMethodEngine
.
PanelType
.
SOFT_KEYBOARD
,
panelFlag
:
FLG_FIXED
panelFlag
:
inputMethodEngine
.
PanelFlag
.
FLG_FIXED
}
}
try
{
try
{
inputMethodEngine
.
getInputMethodAbility
().
createPanel
(
this
.
context
,
panelInfo
,
(
err
,
panel
)
=>
{
inputMethodEngine
.
getInputMethodAbility
().
createPanel
(
this
.
context
,
panelInfo
,
(
err
,
panel
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
log
(
'
Failed to create panel, err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to create panel:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
globalThis
.
inputMethodPanel
=
panel
;
globalThis
.
inputMethodPanel
=
panel
;
console
.
log
(
'
Succeed in creating panel.
'
);
console
.
log
(
'
Succeed in creating panel.
'
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
'
Failed to create panel, err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to create panel:
${
JSON
.
stringify
(
err
)}
`
);
}
}
try
{
try
{
inputMethodEngine
.
getInputMethodAbility
().
destroyPanel
(
globalThis
.
inputMethodPanel
,
(
err
)
=>
{
inputMethodEngine
.
getInputMethodAbility
().
destroyPanel
(
globalThis
.
inputMethodPanel
,
(
err
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
!==
undefined
)
{
console
.
log
(
'
Failed to destroy panel, err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to destroy panel:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
log
(
'
Succeed in destroying panel.
'
);
console
.
log
(
'
Succeed in destroying panel.
'
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
'
Failed to destroy panel, err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to destroy panel:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -631,30 +637,30 @@ destroyPanel(panel: Panel): Promise\<void>;
...
@@ -631,30 +637,30 @@ destroyPanel(panel: Panel): Promise\<void>;
```
js
```
js
let
panelInfo
:
inputMethodEngine
.
PanelInfo
=
{
let
panelInfo
:
inputMethodEngine
.
PanelInfo
=
{
panelType
:
SOFT_KEYBOARD
,
panelType
:
inputMethodEngine
.
PanelType
.
SOFT_KEYBOARD
,
panelFlag
:
FLG_FIXED
panelFlag
:
inputMethodEngine
.
PanelFlag
.
FLG_FIXED
}
}
try
{
try
{
inputMethodEngine
.
getInputMethodAbility
().
createPanel
(
this
.
context
,
panelInfo
,
(
err
,
panel
)
=>
{
inputMethodEngine
.
getInputMethodAbility
().
createPanel
(
this
.
context
,
panelInfo
,
(
err
,
panel
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
log
(
'
Failed to create panel, err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to create panel:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
globalThis
.
inputMethodPanel
=
panel
;
globalThis
.
inputMethodPanel
=
panel
;
console
.
log
(
'
Succeed in creating panel.
'
);
console
.
log
(
'
Succeed in creating panel.
'
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
'
Failed to create panel, err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to create panel:
${
JSON
.
stringify
(
err
)}
`
);
}
}
try
{
try
{
inputMethodEngine
.
getInputMethodAbility
().
destroyPanel
(
globalThis
.
inputMethodPanel
).
then
(()
=>
{
inputMethodEngine
.
getInputMethodAbility
().
destroyPanel
(
globalThis
.
inputMethodPanel
).
then
(()
=>
{
console
.
log
(
'
Succeed in destroying panel.
'
);
console
.
log
(
'
Succeed in destroying panel.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
log
(
'
Failed to destroy panel, err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to destroy panel:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
'
Failed to destroy panel, err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to destroy panel:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -681,13 +687,13 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void
...
@@ -681,13 +687,13 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void
```
js
```
js
inputMethodEngine
.
getKeyboardDelegate
().
on
(
'
keyUp
'
,
(
keyEvent
)
=>
{
inputMethodEngine
.
getKeyboardDelegate
().
on
(
'
keyUp
'
,
(
keyEvent
)
=>
{
console
.
info
(
'
inputMethodEngine keyCode.(keyUp):
'
+
JSON
.
stringify
(
keyEvent
.
keyCode
));
console
.
log
(
'
inputMethodEngine keyCode.(keyUp):
'
+
JSON
.
stringify
(
keyEvent
.
keyCode
));
console
.
info
(
'
inputMethodEngine keyAction.(keyUp):
'
+
JSON
.
stringify
(
keyEvent
.
keyAction
));
console
.
log
(
'
inputMethodEngine keyAction.(keyUp):
'
+
JSON
.
stringify
(
keyEvent
.
keyAction
));
return
true
;
return
true
;
});
});
inputMethodEngine
.
getKeyboardDelegate
().
on
(
'
keyDown
'
,
(
keyEvent
)
=>
{
inputMethodEngine
.
getKeyboardDelegate
().
on
(
'
keyDown
'
,
(
keyEvent
)
=>
{
console
.
info
(
'
inputMethodEngine keyCode.(keyDown):
'
+
JSON
.
stringify
(
keyEvent
.
keyCode
));
console
.
log
(
'
inputMethodEngine keyCode.(keyDown):
'
+
JSON
.
stringify
(
keyEvent
.
keyCode
));
console
.
info
(
'
inputMethodEngine keyAction.(keyDown):
'
+
JSON
.
stringify
(
keyEvent
.
keyAction
));
console
.
log
(
'
inputMethodEngine keyAction.(keyDown):
'
+
JSON
.
stringify
(
keyEvent
.
keyAction
));
return
true
;
return
true
;
});
});
```
```
...
@@ -703,7 +709,7 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void
...
@@ -703,7 +709,7 @@ off(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 | 否 | 回调函数,返回按键信息。 |
| callback | (event:
[
KeyEvent
](
#keyevent
)
) => boolean | 否 | 回调函数,返回按键信息。 |
...
@@ -731,7 +737,7 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) =
...
@@ -731,7 +737,7 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) =
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----
------------------------------------------ | ---- | -------------------------------------------------------
----- |
| -------- | ----
| ---- |
----- |
| type | string | 是 | 光标变化事件。
<br/>
-
type为’cursorContextChange‘时,表示订阅光标变化事件。 |
| type | string | 是 | 光标变化事件。
<br/>
-
type为’cursorContextChange‘时,表示订阅光标变化事件。 |
| callback | (x: number, y: number, height: number) => void | 是 | 回调函数,返回光标信息。
<br/>
-
x为光标上端的的x坐标值。
<br/>
-
y为光标上端的y坐标值。
<br/>
-
height为光标的高度值。 |
| callback | (x: number, y: number, height: number) => void | 是 | 回调函数,返回光标信息。
<br/>
-
x为光标上端的的x坐标值。
<br/>
-
y为光标上端的y坐标值。
<br/>
-
height为光标的高度值。 |
...
@@ -756,7 +762,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y: number, height: numbe
...
@@ -756,7 +762,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y: number, height: numbe
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----
---------------------------------------- | ---- | ------------------------------------------------------
------ |
| -------- | ----
| ---- |
------ |
| type | string | 是 | 光标变化事件。
<br/>
-
type为’cursorContextChange‘时,表示光标变化。 |
| type | string | 是 | 光标变化事件。
<br/>
-
type为’cursorContextChange‘时,表示光标变化。 |
| callback | (x: number, y:number, height:number) => void | 否 | 回调函数,返回光标信息。
<br/>
-
x为光标上端的的x坐标值。
<br/>
-
y为光标上端的y坐标值。
<br/>
-
height为光标的高度值。
<br/>
|
| callback | (x: number, y:number, height:number) => void | 否 | 回调函数,返回光标信息。
<br/>
-
x为光标上端的的x坐标值。
<br/>
-
y为光标上端的y坐标值。
<br/>
-
height为光标的高度值。
<br/>
|
...
@@ -779,7 +785,7 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi
...
@@ -779,7 +785,7 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -----
------------------------------------------------------- | ---- | --------------------------------------------------------
---- |
| -------- | -----
| ---- |
---- |
| type | string | 是 | 文本选择变化事件。
<br/>
-
type为’selectionChange‘时,表示选择文本变化。 |
| type | string | 是 | 文本选择变化事件。
<br/>
-
type为’selectionChange‘时,表示选择文本变化。 |
| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 是 | 回调函数,返回文本选择信息。
<br/>
-
oldBegin为变化之前被选中文本的起始下标。
<br/>
-
oldEnd为变化之前被选中文本的终止下标。
<br/>
-
newBegin为变化之后被选中文本的起始下标。
<br/>
-
newEnd为变化之后被选中文本的终止下标。 |
| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 是 | 回调函数,返回文本选择信息。
<br/>
-
oldBegin为变化之前被选中文本的起始下标。
<br/>
-
oldEnd为变化之前被选中文本的终止下标。
<br/>
-
newBegin为变化之后被选中文本的起始下标。
<br/>
-
newEnd为变化之后被选中文本的终止下标。 |
...
@@ -805,7 +811,7 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe
...
@@ -805,7 +811,7 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------
----------------------------------------------------- | ---- | -----------------------------------------------------
------- |
| -------- | -------
| ---- |
------- |
| type | string | 是 | 文本选择变化事件。
<br/>
-
type为’selectionChange‘时,表示选择文本变化。 |
| type | string | 是 | 文本选择变化事件。
<br/>
-
type为’selectionChange‘时,表示选择文本变化。 |
| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 否 | 回调函数,返回文本选择信息。
<br/>
-
oldBegin为变化之前被选中文本的起始下标。
<br/>
-
oldEnd为变化之前被选中文本的终止下标。
<br/>
-
newBegin为变化之后被选中文本的起始下标。
<br/>
-
newEnd为变化之后被选中文本的终止下标。
<br/>
|
| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 否 | 回调函数,返回文本选择信息。
<br/>
-
oldBegin为变化之前被选中文本的起始下标。
<br/>
-
oldEnd为变化之前被选中文本的终止下标。
<br/>
-
newBegin为变化之后被选中文本的起始下标。
<br/>
-
newEnd为变化之后被选中文本的终止下标。
<br/>
|
...
@@ -831,7 +837,7 @@ on(type: 'textChange', callback: (text: string) => void): void
...
@@ -831,7 +837,7 @@ on(type: 'textChange', callback: (text: string) => void): void
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 文本变化事件。
<br/>
-
type为’textChange‘时,表示订阅文本变化事件。 |
| type | string | 是 | 文本变化事件。
<br/>
-
type为’textChange‘时,表示订阅文本变化事件。 |
| callback | (text: string) => void | 是 | 回调函数,返回订阅的文本内容。
|
| callback | (text: string) => void | 是 | 回调函数,返回订阅的文本内容。|
**示例:**
**示例:**
...
@@ -889,13 +895,13 @@ setUiContent(path: string, callback: AsyncCallback\<void>): void
...
@@ -889,13 +895,13 @@ setUiContent(path: string, callback: AsyncCallback\<void>): void
try
{
try
{
panel
.
setUiContent
(
'
pages/page2/page2
'
,
(
err
)
=>
{
panel
.
setUiContent
(
'
pages/page2/page2
'
,
(
err
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Failed to set the content. err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to setUiContent:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
info
(
'
Succeeded in setting the content.
'
);
console
.
log
(
'
Succeeded in setting the content.
'
);
});
});
}
catch
(
e
xception
)
{
}
catch
(
e
rr
)
{
console
.
error
(
'
Failed to set the content. err:
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
`Failed to setUiContent:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -925,12 +931,12 @@ setUiContent(path: string): Promise\<void>
...
@@ -925,12 +931,12 @@ setUiContent(path: string): Promise\<void>
try
{
try
{
let
promise
=
panel
.
setUiContent
(
'
pages/page2/page2
'
);
let
promise
=
panel
.
setUiContent
(
'
pages/page2/page2
'
);
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
console
.
info
(
'
Succeeded in setting the content.
'
);
console
.
log
(
'
Succeeded in setting the content.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set the content. err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to setUiContent:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
e
xception
)
{
}
catch
(
e
rr
)
{
console
.
error
(
'
Failed to set the content. err:
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
`Failed to setUiContent:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -958,13 +964,13 @@ storage.setOrCreate('storageSimpleProp',121);
...
@@ -958,13 +964,13 @@ storage.setOrCreate('storageSimpleProp',121);
try
{
try
{
panel
.
setUiContent
(
'
pages/page2/page2
'
,
storage
,
(
err
)
=>
{
panel
.
setUiContent
(
'
pages/page2/page2
'
,
storage
,
(
err
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Failed to set the content. err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to setUiContent:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
info
(
'
Succeeded in setting the content.
'
);
console
.
log
(
'
Succeeded in setting the content.
'
);
});
});
}
catch
(
e
xception
)
{
}
catch
(
e
rr
)
{
console
.
error
(
'
Failed to set the content. err:
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
`Failed to setUiContent:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -997,12 +1003,12 @@ storage.setOrCreate('storageSimpleProp',121);
...
@@ -997,12 +1003,12 @@ storage.setOrCreate('storageSimpleProp',121);
try
{
try
{
let
promise
=
panel
.
setUiContent
(
'
pages/page2/page2
'
);
let
promise
=
panel
.
setUiContent
(
'
pages/page2/page2
'
);
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
console
.
info
(
'
Succeeded in setting the content.
'
);
console
.
log
(
'
Succeeded in setting the content.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set the content. err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to setUiContent:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
e
xception
)
{
}
catch
(
e
rr
)
{
console
.
error
(
'
Failed to set the content. err:
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
`Failed to setUiContent:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1011,6 +1017,7 @@ try {
...
@@ -1011,6 +1017,7 @@ try {
resize(width: number, height: number, callback: AsyncCallback
\<
void>): void
resize(width: number, height: number, callback: AsyncCallback
\<
void>): void
改变当前面板大小,使用callback异步回调。
改变当前面板大小,使用callback异步回调。
面板存在大小限制,面板宽度不超出屏幕宽度,面板高度不高于屏幕高度的二分之一。
面板存在大小限制,面板宽度不超出屏幕宽度,面板高度不高于屏幕高度的二分之一。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -1029,13 +1036,13 @@ resize(width: number, height: number, callback: AsyncCallback\<void>): void
...
@@ -1029,13 +1036,13 @@ resize(width: number, height: number, callback: AsyncCallback\<void>): void
try
{
try
{
panel
.
resize
(
500
,
1000
,
(
err
)
=>
{
panel
.
resize
(
500
,
1000
,
(
err
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Failed to change the panel size. Cause:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to resize panel:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
info
(
'
Succeeded in changing the panel size.
'
);
console
.
log
(
'
Succeeded in changing the panel size.
'
);
});
});
}
catch
(
e
xception
)
{
}
catch
(
e
rr
)
{
console
.
error
(
'
Failed to change the panel size. Cause:
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
`Failed to resize panel:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1044,6 +1051,7 @@ try {
...
@@ -1044,6 +1051,7 @@ try {
resize(width: number, height: number): Promise
\<
void>;
resize(width: number, height: number): Promise
\<
void>;
改变当前面板大小,使用Promise异步回调。
改变当前面板大小,使用Promise异步回调。
面板存在大小限制,面板宽度不超出屏幕宽度,面板高度不高于屏幕高度的二分之一。
面板存在大小限制,面板宽度不超出屏幕宽度,面板高度不高于屏幕高度的二分之一。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -1067,12 +1075,12 @@ resize(width: number, height: number): Promise\<void>;
...
@@ -1067,12 +1075,12 @@ resize(width: number, height: number): Promise\<void>;
try
{
try
{
let
promise
=
panel
.
resize
(
500
,
1000
);
let
promise
=
panel
.
resize
(
500
,
1000
);
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
console
.
info
(
'
Succeeded in changing the panel size.
'
);
console
.
log
(
'
Succeeded in changing the panel size.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to change the panel size. err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to resize panel:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
e
xception
)
{
}
catch
(
e
rr
)
{
console
.
error
(
'
Failed to change the panel size. err:
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
`Failed to resize panel:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1081,6 +1089,7 @@ try {
...
@@ -1081,6 +1089,7 @@ try {
moveTo(x: number, y: number, callback: AsyncCallback
\<
void>): void
moveTo(x: number, y: number, callback: AsyncCallback
\<
void>): void
移动面板位置,使用callback异步回调。
移动面板位置,使用callback异步回调。
对FLG_FIXED状态的panel不产生实际移动效果。
对FLG_FIXED状态的panel不产生实际移动效果。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -1099,13 +1108,13 @@ moveTo(x: number, y: number, callback: AsyncCallback\<void>): void
...
@@ -1099,13 +1108,13 @@ moveTo(x: number, y: number, callback: AsyncCallback\<void>): void
try
{
try
{
panel
.
moveTo
(
300
,
300
,
(
err
)
=>
{
panel
.
moveTo
(
300
,
300
,
(
err
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Failed to move the panel. err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to move panel:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
info
(
'
Succeeded in moving the panel.
'
);
console
.
log
(
'
Succeeded in moving the panel.
'
);
});
});
}
catch
(
e
xception
)
{
}
catch
(
e
rr
)
{
console
.
error
(
'
Failed to move the panel. err:
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
`Failed to move panel:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1114,6 +1123,7 @@ try {
...
@@ -1114,6 +1123,7 @@ try {
moveTo(x: number, y: number): Promise
\<
void>
moveTo(x: number, y: number): Promise
\<
void>
移动面板位置,使用callback异步回调。
移动面板位置,使用callback异步回调。
对FLG_FIXED状态的panel不产生实际移动效果。
对FLG_FIXED状态的panel不产生实际移动效果。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -1137,12 +1147,12 @@ moveTo(x: number, y: number): Promise\<void>
...
@@ -1137,12 +1147,12 @@ moveTo(x: number, y: number): Promise\<void>
try
{
try
{
let
promise
=
windowClass
.
moveTo
(
300
,
300
);
let
promise
=
windowClass
.
moveTo
(
300
,
300
);
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
console
.
info
(
'
Succeeded in moving the panel.
'
);
console
.
log
(
'
Succeeded in moving the panel.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to move the panel. Cause:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to move panel:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
e
xception
)
{
}
catch
(
e
rr
)
{
console
.
error
(
'
Failed to move the panel. Cause:
'
+
JSON
.
stringify
(
exception
)
);
console
.
error
(
`Failed to move panel:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1165,10 +1175,10 @@ show(callback: AsyncCallback\<void>): void
...
@@ -1165,10 +1175,10 @@ show(callback: AsyncCallback\<void>): void
```
js
```
js
panel
.
show
((
err
)
=>
{
panel
.
show
((
err
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Failed to show the panel. Cause:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to show panel:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
info
(
'
Succeeded in showing the panel.
'
);
console
.
log
(
'
Succeeded in showing the panel.
'
);
});
});
```
```
...
@@ -1191,9 +1201,9 @@ show(): Promise\<void>
...
@@ -1191,9 +1201,9 @@ show(): Promise\<void>
```
js
```
js
let
promise
=
panel
.
show
();
let
promise
=
panel
.
show
();
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
console
.
info
(
'
Succeeded in showing the panel.
'
);
console
.
log
(
'
Succeeded in showing the panel.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to show the panel. err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to show panel:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -1216,10 +1226,10 @@ hide(callback: AsyncCallback\<void>): void
...
@@ -1216,10 +1226,10 @@ hide(callback: AsyncCallback\<void>): void
```
js
```
js
panel
.
hide
((
err
)
=>
{
panel
.
hide
((
err
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Failed to hide the panel. Cause:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to hide panel:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
info
(
'
Succeeded in hiding the panel.
'
);
console
.
log
(
'
Succeeded in hiding the panel.
'
);
});
});
```
```
...
@@ -1242,9 +1252,9 @@ hide(): Promise\<void>
...
@@ -1242,9 +1252,9 @@ hide(): Promise\<void>
```
js
```
js
let
promise
=
panel
.
hide
();
let
promise
=
panel
.
hide
();
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
console
.
info
(
'
Succeeded in hiding the panel.
'
);
console
.
log
(
'
Succeeded in hiding the panel.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to hide the panel. err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to hide panel:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -1252,7 +1262,7 @@ promise.then(() => {
...
@@ -1252,7 +1262,7 @@ promise.then(() => {
on(type: 'show' | 'hide', callback: () => void): void
on(type: 'show' | 'hide', callback: () => void): void
监听当前面板状态,
可监听面板类型为show或者hide,
使用callback异步回调。
监听当前面板状态,使用callback异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -1267,7 +1277,7 @@ on(type: 'show' | 'hide', callback: () => void): void
...
@@ -1267,7 +1277,7 @@ on(type: 'show' | 'hide', callback: () => void): void
```
js
```
js
panel
.
on
(
'
show
'
,
()
=>
{
panel
.
on
(
'
show
'
,
()
=>
{
console
.
info
(
'
Panel is showing.
'
);
console
.
log
(
'
Panel is showing.
'
);
});
});
```
```
...
@@ -1275,7 +1285,7 @@ panel.on('show', () => {
...
@@ -1275,7 +1285,7 @@ panel.on('show', () => {
off(type: 'show' | 'hide', callback?: () => void): void
off(type: 'show' | 'hide', callback?: () => void): void
取消监听当前面板状态,
可取消监听的面板类型为show或者hide,
使用callback异步回调。
取消监听当前面板状态,使用callback异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -1283,7 +1293,7 @@ off(type: 'show' | 'hide', callback?: () => void): void
...
@@ -1283,7 +1293,7 @@ off(type: 'show' | 'hide', callback?: () => void): void
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | -------- |
| -------- | ---------------------- | ---- | -------- |
| type | 'show'
/
'hide' | 是 | 要取消监听的当前面板状态类型,show表示显示状态,hide表示隐藏状态 |
| type | 'show'
\|
'hide' | 是 | 要取消监听的当前面板状态类型,show表示显示状态,hide表示隐藏状态 |
| callback | () => void | 否 | 回调函数。 |
| callback | () => void | 否 | 回调函数。 |
**示例:**
**示例:**
...
@@ -1343,8 +1353,8 @@ hide(callback: AsyncCallback<void>): void
...
@@ -1343,8 +1353,8 @@ hide(callback: AsyncCallback<void>): void
```
js
```
js
keyboardController
.
hide
((
err
)
=>
{
keyboardController
.
hide
((
err
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to hide keyboard:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to hide:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
log
(
'
Succeeded in hiding keyboard.
'
);
console
.
log
(
'
Succeeded in hiding keyboard.
'
);
...
@@ -1377,9 +1387,9 @@ hide(): Promise<void>
...
@@ -1377,9 +1387,9 @@ hide(): Promise<void>
```
js
```
js
keyboardController
.
hide
().
then
(()
=>
{
keyboardController
.
hide
().
then
(()
=>
{
console
.
info
(
'
Succeeded in hiding keyboard.
'
);
console
.
log
(
'
Succeeded in hiding keyboard.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
info
(
'
Failed to hide keyboard:
'
+
JSON
.
stringify
(
err
)
);
console
.
log
(
`Failed to hide:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -1391,7 +1401,7 @@ hideKeyboard(callback: AsyncCallback<void>): void
...
@@ -1391,7 +1401,7 @@ hideKeyboard(callback: AsyncCallback<void>): void
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[hide](#hide9)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[hide](#hide9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -1405,8 +1415,8 @@ hideKeyboard(callback: AsyncCallback<void>): void
...
@@ -1405,8 +1415,8 @@ hideKeyboard(callback: AsyncCallback<void>): void
```
js
```
js
keyboardController
.
hideKeyboard
((
err
)
=>
{
keyboardController
.
hideKeyboard
((
err
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to hide Keyboard:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to hideKeyboard:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
log
(
'
Succeeded in hiding keyboard.
'
);
console
.
log
(
'
Succeeded in hiding keyboard.
'
);
...
@@ -1421,7 +1431,7 @@ hideKeyboard(): Promise<void>
...
@@ -1421,7 +1431,7 @@ hideKeyboard(): Promise<void>
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[hide](#hide9-1)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[hide](#hide9-1)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -1435,12 +1445,59 @@ hideKeyboard(): Promise<void>
...
@@ -1435,12 +1445,59 @@ hideKeyboard(): Promise<void>
```
js
```
js
keyboardController
.
hideKeyboard
().
then
(()
=>
{
keyboardController
.
hideKeyboard
().
then
(()
=>
{
console
.
info
(
'
Succeeded in hiding keyboard.
'
);
console
.
log
(
'
Succeeded in hiding keyboard.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
info
(
'
Failed to hide Keyboard:
'
+
JSON
.
stringify
(
err
)
);
console
.
log
(
`Failed to hideKeyboard:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
## ExtendAction<sup>10+</sup>
对编辑框中文本的扩展编辑操作类型。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
| 名称 | 值 |说明 |
| -------- | -------- |-------- |
| SELECT_ALL | 0 |全选。 |
| CUT | 3 |剪切。 |
| COPY | 4 |复制。 |
| PASTE | 5 |粘贴。 |
## Direction<sup>10+</sup>
输入法光标移动方向。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
| 名称 | 值 |说明 |
| -------- | -------- |-------- |
| CURSOR_UP | 1 |向上。 |
| CURSOR_DOWN | 2 |向下。 |
| CURSOR_LEFT | 3 |向左。 |
| CURSOR_RIGHT | 4 |向右。 |
## Range<sup>10+</sup>
描述选中文本的范围。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| start | number | 是 | 是 | 选中文本的首字符在编辑框的索引值。|
| end | number | 是 | 是 | 选中文本的末字符在编辑框的索引值。|
## Movement<sup>10+</sup>
描述进行选中文本动作时光标移动的方向。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| direction |
[
Direction
](
#direction10
)
| 是 | 是 | 进行选中文本动作时光标移动的方向。|
## InputClient<sup>9+</sup>
## InputClient<sup>9+</sup>
下列API示例中都需使用
[
on('inputStart')
](
#oninputstart9
)
回调获取到InputClient实例,再通过此实例调用对应方法。
下列API示例中都需使用
[
on('inputStart')
](
#oninputstart9
)
回调获取到InputClient实例,再通过此实例调用对应方法。
...
@@ -1457,7 +1514,7 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void
...
@@ -1457,7 +1514,7 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| action | number | 是 | 功能键键值。
<br/>
当值为0时,表示无效按键;
<br/>
当值为1时,表示确认键(即回车键)。 |
| action | number | 是 | 功能键键值。
<br/>
- 当值为0时,表示无效按键;
<br/>
-
当值为1时,表示确认键(即回车键)。 |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当功能键发送成功,err为undefined,data为true;否则为错误对象。 |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当功能键发送成功,err为undefined,data为true;否则为错误对象。 |
**错误码:**
**错误码:**
...
@@ -1474,18 +1531,18 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void
...
@@ -1474,18 +1531,18 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void
let
action
=
1
;
let
action
=
1
;
try
{
try
{
inputClient
.
sendKeyFunction
(
action
,
(
err
,
result
)
=>
{
inputClient
.
sendKeyFunction
(
action
,
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to sendKeyFunction:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to sendKeyFunction:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in sending key function.
'
);
console
.
log
(
'
Succeeded in sending key function.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to sendKeyFunction.
'
);
console
.
error
(
'
Failed to sendKeyFunction.
'
);
}
}
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
sendKeyFunction err:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to sendKeyFunction:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1524,15 +1581,15 @@ let action = 1;
...
@@ -1524,15 +1581,15 @@ let action = 1;
try
{
try
{
inputClient
.
sendKeyFunction
(
action
).
then
((
result
)
=>
{
inputClient
.
sendKeyFunction
(
action
).
then
((
result
)
=>
{
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in sending key function.
'
);
console
.
log
(
'
Succeeded in sending key function.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to sendKeyFunction.
'
);
console
.
error
(
'
Failed to sendKeyFunction.
'
);
}
}
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to sendKeyFunction:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to sendKeyFunction:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to sendKeyFunction:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to sendKeyFunction:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1566,14 +1623,14 @@ getForward(length:number, callback: AsyncCallback<string>): void
...
@@ -1566,14 +1623,14 @@ getForward(length:number, callback: AsyncCallback<string>): void
let
length
=
1
;
let
length
=
1
;
try
{
try
{
inputClient
.
getForward
(
length
,
(
err
,
text
)
=>
{
inputClient
.
getForward
(
length
,
(
err
,
text
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to getForward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getForward:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
log
(
'
Succeeded in getting forward, text:
'
+
text
);
console
.
log
(
'
Succeeded in getting forward, text:
'
+
text
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to getForward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getForward:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1612,12 +1669,12 @@ getForward(length:number): Promise<string>
...
@@ -1612,12 +1669,12 @@ getForward(length:number): Promise<string>
let
length
=
1
;
let
length
=
1
;
try
{
try
{
inputClient
.
getForward
(
length
).
then
((
text
)
=>
{
inputClient
.
getForward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
Succeeded in getting forward, text:
'
+
text
);
console
.
log
(
'
Succeeded in getting forward, text:
'
+
text
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to getForward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getForward:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to getForward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getForward:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1651,14 +1708,14 @@ getBackward(length:number, callback: AsyncCallback<string>): void
...
@@ -1651,14 +1708,14 @@ getBackward(length:number, callback: AsyncCallback<string>): void
let
length
=
1
;
let
length
=
1
;
try
{
try
{
inputClient
.
getBackward
(
length
,
(
err
,
text
)
=>
{
inputClient
.
getBackward
(
length
,
(
err
,
text
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to getForward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getBackward:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
log
(
'
Succeeded in getting backward, text:
'
+
text
);
console
.
log
(
'
Succeeded in getting backward, text:
'
+
text
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to getForward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getBackward:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1697,12 +1754,12 @@ getBackward(length:number): Promise<string>
...
@@ -1697,12 +1754,12 @@ getBackward(length:number): Promise<string>
let
length
=
1
;
let
length
=
1
;
try
{
try
{
inputClient
.
getBackward
(
length
).
then
((
text
)
=>
{
inputClient
.
getBackward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
Succeeded in getting backward, text:
'
+
text
);
console
.
log
(
'
Succeeded in getting backward, text:
'
+
text
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to getForward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getBackward:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to getForward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getBackward:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1736,18 +1793,18 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void
...
@@ -1736,18 +1793,18 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void
let
length
=
1
;
let
length
=
1
;
try
{
try
{
inputClient
.
deleteForward
(
length
,
(
err
,
result
)
=>
{
inputClient
.
deleteForward
(
length
,
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to delete forward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to deleteForward:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in deleting forward.
'
);
console
.
log
(
'
Succeeded in deleting forward.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to delete forward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to deleteForward:
${
JSON
.
stringify
(
err
)}
`
);
}
}
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to delete forward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to deleteForward:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1787,15 +1844,15 @@ let length = 1;
...
@@ -1787,15 +1844,15 @@ let length = 1;
try
{
try
{
inputClient
.
deleteForward
(
length
).
then
((
result
)
=>
{
inputClient
.
deleteForward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in deleting forward.
'
);
console
.
log
(
'
Succeeded in deleting forward.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to delete Forward.
'
);
console
.
error
(
'
Failed to delete Forward.
'
);
}
}
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to delete Forward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to deleteForward:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to delete Forward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to deleteForward:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -1829,14 +1886,14 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void
...
@@ -1829,14 +1886,14 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void
let
length
=
1
;
let
length
=
1
;
try
{
try
{
inputClient
.
deleteBackward
(
length
,
(
err
,
result
)
=>
{
inputClient
.
deleteBackward
(
length
,
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to delete Backward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to deleteBackward:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in deleting backward.
'
);
console
.
log
(
'
Succeeded in deleting backward.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to delete Backward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to deleteBackward:
${
JSON
.
stringify
(
err
)}
`
);
}
}
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1879,12 +1936,12 @@ deleteBackward(length:number): Promise<boolean>
...
@@ -1879,12 +1936,12 @@ deleteBackward(length:number): Promise<boolean>
let
length
=
1
;
let
length
=
1
;
inputClient
.
deleteBackward
(
length
).
then
((
result
)
=>
{
inputClient
.
deleteBackward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in deleting backward.
'
);
console
.
log
(
'
Succeeded in deleting backward.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to deleteBackward.
'
);
console
.
error
(
'
Failed to deleteBackward.
'
);
}
}
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to deleteBackward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to deleteBackward:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -1916,14 +1973,14 @@ insertText(text:string, callback: AsyncCallback<boolean>): void
...
@@ -1916,14 +1973,14 @@ insertText(text:string, callback: AsyncCallback<boolean>): void
```
js
```
js
inputClient
.
insertText
(
'
test
'
,
(
err
,
result
)
=>
{
inputClient
.
insertText
(
'
test
'
,
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to insertText:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to insertText:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in inserting text.
'
);
console
.
log
(
'
Succeeded in inserting text.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to insertText.
'
);
console
.
error
(
'
Failed to insertText.
'
);
}
}
});
});
```
```
...
@@ -1963,15 +2020,15 @@ insertText(text:string): Promise<boolean>
...
@@ -1963,15 +2020,15 @@ insertText(text:string): Promise<boolean>
try
{
try
{
inputClient
.
insertText
(
'
test
'
).
then
((
result
)
=>
{
inputClient
.
insertText
(
'
test
'
).
then
((
result
)
=>
{
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in inserting text.
'
);
console
.
log
(
'
Succeeded in inserting text.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to insertText.
'
);
console
.
error
(
'
Failed to insertText.
'
);
}
}
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to insertText:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to insertText:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to insertText:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to insertText:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -2001,8 +2058,8 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void
...
@@ -2001,8 +2058,8 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void
```
js
```
js
inputClient
.
getEditorAttribute
((
err
,
editorAttribute
)
=>
{
inputClient
.
getEditorAttribute
((
err
,
editorAttribute
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to getEditorAttribute:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getEditorAttribute:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
log
(
'
editorAttribute.inputPattern:
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
console
.
log
(
'
editorAttribute.inputPattern:
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
...
@@ -2036,10 +2093,10 @@ getEditorAttribute(): Promise<EditorAttribute>
...
@@ -2036,10 +2093,10 @@ getEditorAttribute(): Promise<EditorAttribute>
```
js
```
js
inputClient
.
getEditorAttribute
().
then
((
editorAttribute
)
=>
{
inputClient
.
getEditorAttribute
().
then
((
editorAttribute
)
=>
{
console
.
info
(
'
editorAttribute.inputPattern:
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
console
.
log
(
'
editorAttribute.inputPattern:
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
console
.
info
(
'
editorAttribute.enterKeyType:
'
+
JSON
.
stringify
(
editorAttribute
.
enterKeyType
));
console
.
log
(
'
editorAttribute.enterKeyType:
'
+
JSON
.
stringify
(
editorAttribute
.
enterKeyType
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to getEditorAttribute:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getEditorAttribute:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -2071,14 +2128,14 @@ moveCursor(direction: number, callback: AsyncCallback<void>): void
...
@@ -2071,14 +2128,14 @@ moveCursor(direction: number, callback: AsyncCallback<void>): void
```
js
```
js
try
{
try
{
inputClient
.
moveCursor
(
inputMethodEngine
.
CURSOR_UP
,
(
err
)
=>
{
inputClient
.
moveCursor
(
inputMethodEngine
.
CURSOR_UP
,
(
err
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to moveCursor:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to moveCursor:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
info
(
'
Succeeded in moving cursor.
'
);
console
.
log
(
'
Succeeded in moving cursor.
'
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to moveCursor:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to moveCursor:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -2117,10 +2174,10 @@ try {
...
@@ -2117,10 +2174,10 @@ try {
inputClient
.
moveCursor
(
inputMethodEngine
.
CURSOR_UP
).
then
(()
=>
{
inputClient
.
moveCursor
(
inputMethodEngine
.
CURSOR_UP
).
then
(()
=>
{
console
.
log
(
'
Succeeded in moving cursor.
'
);
console
.
log
(
'
Succeeded in moving cursor.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to moveCursor:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to moveCursor:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
'
Failed to moveCursor:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to moveCursor:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -2136,7 +2193,7 @@ selectByRange(range: Range, callback: AsyncCallback<void>): void
...
@@ -2136,7 +2193,7 @@ selectByRange(range: Range, callback: AsyncCallback<void>): void
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| range |
[
Range
](
./js-apis-inputmethod-InputMethodCommon.md#range
)
| 是 | 选中文本的范围。 |
| range |
[
Range
](
#range10
)
| 是 | 选中文本的范围。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当成功发送选中事件后,err为undefined,否则为错误对象。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当成功发送选中事件后,err为undefined,否则为错误对象。 |
**错误码:**
**错误码:**
...
@@ -2153,14 +2210,14 @@ selectByRange(range: Range, callback: AsyncCallback<void>): void
...
@@ -2153,14 +2210,14 @@ selectByRange(range: Range, callback: AsyncCallback<void>): void
```
js
```
js
try
{
try
{
inputClient
.
selectByRange
({
start
:
0
,
end
:
1
},
(
err
)
=>
{
inputClient
.
selectByRange
({
start
:
0
,
end
:
1
},
(
err
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to selectByRange: ${err.message}
'
);
console
.
error
(
`Failed to selectByRange:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
info
(
'
Succeeded in selecting by range.
'
);
console
.
log
(
'
Succeeded in selecting by range.
'
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to selectByRange: ${err.message}
'
);
console
.
error
(
`Failed to selectByRange:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -2176,7 +2233,7 @@ selectByRange(range: Range): Promise<void>
...
@@ -2176,7 +2233,7 @@ selectByRange(range: Range): Promise<void>
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| ------ | --------------------------------------------------------- | ---- | ---------------- |
| ------ | --------------------------------------------------------- | ---- | ---------------- |
| range |
[
Range
](
./js-apis-inputmethod-InputMethodCommon.md#range
)
| 是 | 选中文本的范围。 |
| range |
[
Range
](
#range10
)
| 是 | 选中文本的范围。 |
**返回值:**
**返回值:**
...
@@ -2200,10 +2257,10 @@ try {
...
@@ -2200,10 +2257,10 @@ try {
inputClient
.
selectByRange
({
start
:
0
,
end
:
1
}).
then
(()
=>
{
inputClient
.
selectByRange
({
start
:
0
,
end
:
1
}).
then
(()
=>
{
console
.
log
(
'
Succeeded in selecting by range.
'
);
console
.
log
(
'
Succeeded in selecting by range.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to selectByRange: ${err.message}
'
);
console
.
error
(
`Failed to selectByRange:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
'
Failed to selectByRange: ${err.message}
'
);
console
.
error
(
`Failed to selectByRange:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -2218,8 +2275,8 @@ selectByMovement(movement: Movement, callback: AsyncCallback<void>): void
...
@@ -2218,8 +2275,8 @@ selectByMovement(movement: Movement, callback: AsyncCallback<void>): void
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------
------------------------------------------------------ | ---- | ------------------------------------------------------
------ |
| -------- | ------
| ---- |
------ |
| movement |
[
Movement
](
./js-apis-inputmethod-InputMethodCommon.md#movement
)
| 是 | 选中时光标移动的方向。
|
| movement |
[
Movement
](
#movement10
)
| 是 | 选中时光标移动的方向。
|
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当成功发送选中事件后,err为undefined,否则为错误对象。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当成功发送选中事件后,err为undefined,否则为错误对象。 |
**错误码:**
**错误码:**
...
@@ -2236,14 +2293,14 @@ selectByMovement(movement: Movement, callback: AsyncCallback<void>): void
...
@@ -2236,14 +2293,14 @@ selectByMovement(movement: Movement, callback: AsyncCallback<void>): void
```
js
```
js
try
{
try
{
inputClient
.
selectByMovement
({
direction
:
1
},
(
err
)
=>
{
inputClient
.
selectByMovement
({
direction
:
1
},
(
err
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to selectByMovement: ${err.message}
'
);
console
.
error
(
`Failed to selectByMovement:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
info
(
'
Succeeded in selecting by movement.
'
);
console
.
log
(
'
Succeeded in selecting by movement.
'
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
'
Failed to selectByMovement: ${err.message}
'
);
console
.
error
(
`Failed to selectByMovement:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -2259,7 +2316,7 @@ selectByMovement(movement: Movement): Promise<void>
...
@@ -2259,7 +2316,7 @@ selectByMovement(movement: Movement): Promise<void>
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ---------------------- |
| -------- | ------------------------------------------------------------ | ---- | ---------------------- |
| movement |
[
Movement
](
./js-apis-inputmethod-InputMethodCommon.md#movement
)
| 是 | 选中时光标移动的方向。 |
| movement |
[
Movement
](
#movement10
)
| 是 | 选中时光标移动的方向。 |
**返回值:**
**返回值:**
...
@@ -2283,10 +2340,10 @@ try {
...
@@ -2283,10 +2340,10 @@ try {
inputClient
.
selectByMovement
({
direction
:
1
}).
then
(()
=>
{
inputClient
.
selectByMovement
({
direction
:
1
}).
then
(()
=>
{
console
.
log
(
'
Succeeded in selecting by movement.
'
);
console
.
log
(
'
Succeeded in selecting by movement.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to selectByMovement: ${err.message}
'
);
console
.
error
(
`Failed to selectByMovement:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
'
Failed to selectByMovement: ${err.message}
'
);
console
.
error
(
`Failed to selectByMovement:
${
JSON
.
stringify
(
err
)}
`
);
}
}
```
```
...
@@ -2310,7 +2367,6 @@ getTextIndexAtCursor(callback: AsyncCallback<number>): void
...
@@ -2310,7 +2367,6 @@ getTextIndexAtCursor(callback: AsyncCallback<number>): void
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
| -------- | ------------------------------ |
| -------- | ------------------------------ |
| 401 | parameter error. |
| 12800003 | input method client error. |
| 12800003 | input method client error. |
| 12800006 | Input method controller error. |
| 12800006 | Input method controller error. |
...
@@ -2318,11 +2374,11 @@ getTextIndexAtCursor(callback: AsyncCallback<number>): void
...
@@ -2318,11 +2374,11 @@ getTextIndexAtCursor(callback: AsyncCallback<number>): void
```
js
```
js
inputClient
.
getTextIndexAtCursor
((
err
,
index
)
=>
{
inputClient
.
getTextIndexAtCursor
((
err
,
index
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to getTextIndexAtCursor: ${err.message}
'
);
console
.
error
(
`Failed to getTextIndexAtCursor:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
info
(
'
Succeeded in getTextIndexAtCursor:
'
+
index
);
console
.
log
(
'
Succeeded in getTextIndexAtCursor:
'
+
index
);
});
});
```
```
...
@@ -2353,12 +2409,99 @@ getTextIndexAtCursor(): Promise<number>
...
@@ -2353,12 +2409,99 @@ getTextIndexAtCursor(): Promise<number>
```
js
```
js
inputClient
.
getTextIndexAtCursor
().
then
((
index
)
=>
{
inputClient
.
getTextIndexAtCursor
().
then
((
index
)
=>
{
console
.
info
(
'
Succeeded in getTextIndexAtCursor:
'
+
index
);
console
.
log
(
'
Succeeded in getTextIndexAtCursor:
'
+
index
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to getTextIndexAtCursor: ${err.message}
'
);
console
.
error
(
`Failed to getTextIndexAtCursor:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
### sendExtendAction<sup>10+</sup>
sendExtendAction(action: ExtendAction, callback: AsyncCallback
<
void
>
): void
发送扩展编辑操作。使用callback异步回调。
输入法应用调用该接口向编辑控件(如:输入框)发送扩展编辑操作,编辑控件监听相应事件
[
on(handleExtendAction)
](
./js-apis-inputmethod.md#onhandleextendaction10
)
,从而进一步做出处理。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
| action |
[
ExtendAction
](
#extendaction10
)
| 是 | 要发送的扩展操作。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。发送成功,err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | ------------------------------ |
| 12800003 | input method client error. |
| 12800006 | Input method controller error. |
**示例:**
```
js
try
{
inputClient
.
sendExtendAction
(
inputMethodEngine
.
ExtendAction
.
COPY
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to sendExtendAction:
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
console
.
log
(
'
Succeeded in sending extend action.
'
);
});
}
catch
(
err
)
{
console
.
error
(
`Failed to sendExtendAction:
${
JSON
.
stringify
(
err
)}
`
);
}
```
### sendExtendAction<sup>10+</sup>
sendExtendAction(action: ExtendAction): Promise
<
void
>
发送扩展编辑操作。使用promise异步回调。
输入法应用调用该接口向编辑控件(如:输入框)发送扩展编辑操作,编辑控件监听相应事件
[
on(handleExtendAction)
](
./js-apis-inputmethod.md#onhandleextendaction10
)
,从而进一步做出处理。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| action |
[
ExtendAction
](
#extendaction10
)
| 是 | 要发送的扩展操作。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | --------------------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | ------------------------------ |
| 12800003 | Input method client error. |
| 12800006 | Input method controller error. |
**示例:**
```
js
try
{
inputClient
.
sendExtendAction
(
inputMethodEngine
.
ExtendAction
.
COPY
).
then
(()
=>
{
console
.
log
(
'
Succeeded in sending extend action.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to sendExtendAction:
${
JSON
.
stringify
(
err
)}
`
);
});
}
catch
(
err
)
{
console
.
error
(
`Failed to sendExtendAction:
${
JSON
.
stringify
(
err
)}
`
);
}
```
## EditorAttribute
## EditorAttribute
编辑框属性值。
编辑框属性值。
...
@@ -2418,7 +2561,7 @@ inputClient.getTextIndexAtCursor().then((index) => {
...
@@ -2418,7 +2561,7 @@ inputClient.getTextIndexAtCursor().then((index) => {
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[InputClient](#inputclient9)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[InputClient](#inputclient9)替代。
下列API示例中都需使用
[
on('inputStart')
](
#oninputstart
)
回调获取到TextInputClient实例,再通过此实例调用对应方法。
下列API示例中都需使用
[
on('inputStart')
](
#oninputstart
)
回调获取到TextInputClient实例,再通过此实例调用对应方法。
...
@@ -2430,7 +2573,7 @@ getForward(length:number, callback: AsyncCallback<string>): void
...
@@ -2430,7 +2573,7 @@ getForward(length:number, callback: AsyncCallback<string>): void
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[getForward](#getforward9)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[getForward](#getforward9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -2446,8 +2589,8 @@ getForward(length:number, callback: AsyncCallback<string>): void
...
@@ -2446,8 +2589,8 @@ getForward(length:number, callback: AsyncCallback<string>): void
```
js
```
js
let
length
=
1
;
let
length
=
1
;
textInputClient
.
getForward
(
length
,
(
err
,
text
)
=>
{
textInputClient
.
getForward
(
length
,
(
err
,
text
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to getForward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getForward:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
log
(
'
Succeeded in getting forward, text:
'
+
text
);
console
.
log
(
'
Succeeded in getting forward, text:
'
+
text
);
...
@@ -2462,7 +2605,7 @@ getForward(length:number): Promise<string>
...
@@ -2462,7 +2605,7 @@ getForward(length:number): Promise<string>
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[getForward](#getforward9)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[getForward](#getforward9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -2483,9 +2626,9 @@ getForward(length:number): Promise<string>
...
@@ -2483,9 +2626,9 @@ getForward(length:number): Promise<string>
```
js
```
js
let
length
=
1
;
let
length
=
1
;
textInputClient
.
getForward
(
length
).
then
((
text
)
=>
{
textInputClient
.
getForward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
Succeeded in getting forward, text:
'
+
text
);
console
.
log
(
'
Succeeded in getting forward, text:
'
+
text
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to getForward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getForward:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -2497,7 +2640,7 @@ getBackward(length:number, callback: AsyncCallback<string>): void
...
@@ -2497,7 +2640,7 @@ getBackward(length:number, callback: AsyncCallback<string>): void
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[getBackward](#getbackward9)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[getBackward](#getbackward9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -2513,8 +2656,8 @@ getBackward(length:number, callback: AsyncCallback<string>): void
...
@@ -2513,8 +2656,8 @@ getBackward(length:number, callback: AsyncCallback<string>): void
```
js
```
js
let
length
=
1
;
let
length
=
1
;
textInputClient
.
getBackward
(
length
,
(
err
,
text
)
=>
{
textInputClient
.
getBackward
(
length
,
(
err
,
text
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to getBackward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getBackward:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
log
(
'
Succeeded in getting borward, text:
'
+
text
);
console
.
log
(
'
Succeeded in getting borward, text:
'
+
text
);
...
@@ -2529,7 +2672,7 @@ getBackward(length:number): Promise<string>
...
@@ -2529,7 +2672,7 @@ getBackward(length:number): Promise<string>
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[getBackward](#getbackward9)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[getBackward](#getbackward9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -2550,9 +2693,9 @@ getBackward(length:number): Promise<string>
...
@@ -2550,9 +2693,9 @@ getBackward(length:number): Promise<string>
```
js
```
js
let
length
=
1
;
let
length
=
1
;
textInputClient
.
getBackward
(
length
).
then
((
text
)
=>
{
textInputClient
.
getBackward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
Succeeded in getting backward:
'
+
JSON
.
stringify
(
text
));
console
.
log
(
'
Succeeded in getting backward:
'
+
JSON
.
stringify
(
text
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to getBackward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getBackward:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -2564,7 +2707,7 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void
...
@@ -2564,7 +2707,7 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[deleteForward](#deleteforward9)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[deleteForward](#deleteforward9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -2580,14 +2723,14 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void
...
@@ -2580,14 +2723,14 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void
```
js
```
js
let
length
=
1
;
let
length
=
1
;
textInputClient
.
deleteForward
(
length
,
(
err
,
result
)
=>
{
textInputClient
.
deleteForward
(
length
,
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to deleteForward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to deleteForward:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in deleting forward.
'
);
console
.
log
(
'
Succeeded in deleting forward.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to deleteForward.
'
);
console
.
error
(
'
Failed to deleteForward.
'
);
}
}
});
});
```
```
...
@@ -2600,7 +2743,7 @@ deleteForward(length:number): Promise<boolean>
...
@@ -2600,7 +2743,7 @@ deleteForward(length:number): Promise<boolean>
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[deleteForward](#deleteforward9)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[deleteForward](#deleteforward9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -2622,12 +2765,12 @@ deleteForward(length:number): Promise<boolean>
...
@@ -2622,12 +2765,12 @@ deleteForward(length:number): Promise<boolean>
let
length
=
1
;
let
length
=
1
;
textInputClient
.
deleteForward
(
length
).
then
((
result
)
=>
{
textInputClient
.
deleteForward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in deleting forward.
'
);
console
.
log
(
'
Succeeded in deleting forward.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to delete forward.
'
);
console
.
error
(
'
Failed to delete forward.
'
);
}
}
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to delete forward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to deleteForward:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -2639,30 +2782,30 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void
...
@@ -2639,30 +2782,30 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[deleteBackward](#deletebackward9)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[deleteBackward](#deletebackward9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | -------------- |
| -------- | ---------------------------- | ---- | -------------- |
| length | number | 是 | 文本长度。 |
| length | number | 是 | 文本长度。 |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当光标后固定长度的文本删除成功,err为undefined,data为true;否则为错误对象。|
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当光标后固定长度的文本删除成功,err为undefined,data为true;否则为错误对象。|
**示例:**
**示例:**
```
js
```
js
let
length
=
1
;
let
length
=
1
;
textInputClient
.
deleteBackward
(
length
,
(
err
,
result
)
=>
{
textInputClient
.
deleteBackward
(
length
,
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to delete backward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to deleteBackward:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in deleting backward.
'
);
console
.
log
(
'
Succeeded in deleting backward.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to deleteBackward.
'
);
console
.
error
(
'
Failed to deleteBackward.
'
);
}
}
});
});
```
```
...
@@ -2675,7 +2818,7 @@ deleteBackward(length:number): Promise<boolean>
...
@@ -2675,7 +2818,7 @@ deleteBackward(length:number): Promise<boolean>
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[deleteBackward](#deletebackward9)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[deleteBackward](#deletebackward9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -2697,12 +2840,12 @@ deleteBackward(length:number): Promise<boolean>
...
@@ -2697,12 +2840,12 @@ deleteBackward(length:number): Promise<boolean>
let
length
=
1
;
let
length
=
1
;
textInputClient
.
deleteBackward
(
length
).
then
((
result
)
=>
{
textInputClient
.
deleteBackward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in deleting backward.
'
);
console
.
log
(
'
Succeeded in deleting backward.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to deleteBackward.
'
);
console
.
error
(
'
Failed to deleteBackward.
'
);
}
}
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to deleteBackward:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to deleteBackward:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
### sendKeyFunction<sup>(deprecated)</sup>
### sendKeyFunction<sup>(deprecated)</sup>
...
@@ -2713,30 +2856,30 @@ sendKeyFunction(action: number, callback: AsyncCallback<boolean>): void
...
@@ -2713,30 +2856,30 @@ sendKeyFunction(action: number, callback: AsyncCallback<boolean>): void
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[sendKeyFunction](#sendkeyfunction9)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[sendKeyFunction](#sendkeyfunction9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| action | number | 是 | 功能键键值。
<br/>
当值为0时,表示无效按键;
<br/>
当值为1时,表示确认键(即回车键)。 |
| action | number | 是 | 功能键键值。
<br/>
- 当值为0时,表示无效按键;
<br/>
-
当值为1时,表示确认键(即回车键)。 |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当功能键发送成功,err为undefined,data为true;否则为错误对象。 |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数。当功能键发送成功,err为undefined,data为true;否则为错误对象。 |
**示例:**
**示例:**
```
js
```
js
let
action
=
1
;
let
action
=
1
;
textInputClient
.
sendKeyFunction
(
action
,
(
err
,
result
)
=>
{
textInputClient
.
sendKeyFunction
(
action
,
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to sendKeyFunction:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to sendKeyFunction:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in sending key function.
'
);
console
.
log
(
'
Succeeded in sending key function.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to sendKeyFunction.
'
);
console
.
error
(
'
Failed to sendKeyFunction.
'
);
}
}
});
});
```
```
...
@@ -2749,7 +2892,7 @@ sendKeyFunction(action: number): Promise<boolean>
...
@@ -2749,7 +2892,7 @@ sendKeyFunction(action: number): Promise<boolean>
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[sendKeyFunction](#sendkeyfunction9)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[sendKeyFunction](#sendkeyfunction9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -2771,12 +2914,12 @@ sendKeyFunction(action: number): Promise<boolean>
...
@@ -2771,12 +2914,12 @@ sendKeyFunction(action: number): Promise<boolean>
let
action
=
1
;
let
action
=
1
;
textInputClient
.
sendKeyFunction
(
action
).
then
((
result
)
=>
{
textInputClient
.
sendKeyFunction
(
action
).
then
((
result
)
=>
{
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in sending key function.
'
);
console
.
log
(
'
Succeeded in sending key function.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to sendKeyFunction.
'
);
console
.
error
(
'
Failed to sendKeyFunction.
'
);
}
}
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to sendKeyFunction:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to sendKeyFunction:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -2788,7 +2931,7 @@ insertText(text:string, callback: AsyncCallback<boolean>): void
...
@@ -2788,7 +2931,7 @@ insertText(text:string, callback: AsyncCallback<boolean>): void
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[insertText](#inserttext9)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[insertText](#inserttext9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -2803,14 +2946,14 @@ insertText(text:string, callback: AsyncCallback<boolean>): void
...
@@ -2803,14 +2946,14 @@ insertText(text:string, callback: AsyncCallback<boolean>): void
```
js
```
js
textInputClient
.
insertText
(
'
test
'
,
(
err
,
result
)
=>
{
textInputClient
.
insertText
(
'
test
'
,
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to insertText:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to insertText:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in inserting text.
'
);
console
.
log
(
'
Succeeded in inserting text.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to insertText.
'
);
console
.
error
(
'
Failed to insertText.
'
);
}
}
});
});
```
```
...
@@ -2823,7 +2966,7 @@ insertText(text:string): Promise<boolean>
...
@@ -2823,7 +2966,7 @@ insertText(text:string): Promise<boolean>
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[insertText](#inserttext9)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[insertText](#inserttext9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -2844,12 +2987,12 @@ insertText(text:string): Promise<boolean>
...
@@ -2844,12 +2987,12 @@ insertText(text:string): Promise<boolean>
```
js
```
js
textInputClient
.
insertText
(
'
test
'
).
then
((
result
)
=>
{
textInputClient
.
insertText
(
'
test
'
).
then
((
result
)
=>
{
if
(
result
)
{
if
(
result
)
{
console
.
info
(
'
Succeeded in inserting text.
'
);
console
.
log
(
'
Succeeded in inserting text.
'
);
}
else
{
}
else
{
console
.
error
(
'
Failed to insertText.
'
);
console
.
error
(
'
Failed to insertText.
'
);
}
}
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to insertText:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to insertText:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -2861,22 +3004,22 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void
...
@@ -2861,22 +3004,22 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[getEditorAttribute](#geteditorattribute9)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[getEditorAttribute](#geteditorattribute9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| --------
----------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -------------------------------------------------------
----- |
| --------
| ----- | ----- |
----- |
| callback | AsyncCallback
<
[EditorAttribute](#editorattribute)
>
| 是 | 回调函数。当编辑框的属性值获取成功,err为undefined,data为编辑框属性值;否则为错误对象。|
| callback | AsyncCallback
<
[EditorAttribute](#editorattribute)
>
| 是 | 回调函数。当编辑框的属性值获取成功,err为undefined,data为编辑框属性值;否则为错误对象。|
**示例:**
**示例:**
```
js
```
js
textInputClient
.
getEditorAttribute
((
err
,
editorAttribute
)
=>
{
textInputClient
.
getEditorAttribute
((
err
,
editorAttribute
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
)
{
console
.
error
(
'
Failed to getEditorAttribute:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getEditorAttribute:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
}
}
console
.
log
(
'
editorAttribute.inputPattern:
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
console
.
log
(
'
editorAttribute.inputPattern:
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
...
@@ -2892,7 +3035,7 @@ getEditorAttribute(): Promise<EditorAttribute>
...
@@ -2892,7 +3035,7 @@ getEditorAttribute(): Promise<EditorAttribute>
> **说明:**
> **说明:**
>
>
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[getEditorAttribute](#geteditorattribute9)替代。
> 从API version 8开始支持,API version 9开始废弃
,
建议使用[getEditorAttribute](#geteditorattribute9)替代。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
@@ -2906,10 +3049,10 @@ getEditorAttribute(): Promise<EditorAttribute>
...
@@ -2906,10 +3049,10 @@ getEditorAttribute(): Promise<EditorAttribute>
```
js
```
js
textInputClient
.
getEditorAttribute
().
then
((
editorAttribute
)
=>
{
textInputClient
.
getEditorAttribute
().
then
((
editorAttribute
)
=>
{
console
.
info
(
'
editorAttribute.inputPattern:
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
console
.
log
(
'
editorAttribute.inputPattern:
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
console
.
info
(
'
editorAttribute.enterKeyType:
'
+
JSON
.
stringify
(
editorAttribute
.
enterKeyType
));
console
.
log
(
'
editorAttribute.enterKeyType:
'
+
JSON
.
stringify
(
editorAttribute
.
enterKeyType
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to getEditorAttribute:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`Failed to getEditorAttribute:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
<!--no_check-->
<!--no_check-->
\ No newline at end of file
zh-cn/application-dev/reference/errorcodes/errorcode-inputmethod-framework.md
浏览文件 @
af32ae67
...
@@ -58,23 +58,23 @@ Input method client error.
...
@@ -58,23 +58,23 @@ Input method client error.
重新将输入法应用与三方应用进行绑定:将三方应用后台进程杀死,重新启动三方应用,通过点击对话框等方式触发输入法键盘的显示,若键盘正常显示,则问题解决。
重新将输入法应用与三方应用进行绑定:将三方应用后台进程杀死,重新启动三方应用,通过点击对话框等方式触发输入法键盘的显示,若键盘正常显示,则问题解决。
## 12800004
按键事件处理异常
## 12800004
不是输入法应用
**错误信息**
**错误信息**
Key event processing error
.
Not an input method extension
.
**错误描述**
**错误描述**
当
按键事件异常
时,系统会报此错误码。
当
其他应用调用了仅支持输入法应用调用的接口
时,系统会报此错误码。
**可能原因**
**可能原因**
按键事件分发、消费、监听异常时会报错
。
在其他应用中调用了仅支持输入法应用调用的接口
。
**处理步骤**
**处理步骤**
无
在输入法应用中调用此接口。
## 12800005 配置固化失败
## 12800005 配置固化失败
...
@@ -147,3 +147,21 @@ Input method manager service error.
...
@@ -147,3 +147,21 @@ Input method manager service error.
**处理步骤**
**处理步骤**
通过ps -A|grep inputmethod查看是否存在输入法服务的进程号,如果存在,则服务正常。
通过ps -A|grep inputmethod查看是否存在输入法服务的进程号,如果存在,则服务正常。
## 12800009 输入法客户端未绑定
**错误信息**
Input method client is detached.
**错误描述**
当前应用未绑定输入法应用。
**可能原因**
当前应用在没有绑定输入法的情况下执行了比如showTextInput、hideTextInput等操作。
**处理步骤**
先执行attach接口操作即可。
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录