Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lfmiao0
Docs
提交
568bc28a
D
Docs
项目概览
lfmiao0
/
Docs
与 Fork 源项目一致
Fork自
OpenHarmony / Docs
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
568bc28a
编写于
11月 10, 2022
作者:
H
Hollokin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【输入法框架】【3.1Release】inputmethod.md资料问题整改
Signed-off-by:
N
Hollokin
<
taoyuxin2@huawei.com
>
上级
4f377ca2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
96 addition
and
73 deletion
+96
-73
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
+96
-73
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
浏览文件 @
568bc28a
# 输入法框架
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
本模块提供对输入法框架的管理,包括隐藏输入法、查询已安装的输入法列表和拉起选择输入法弹窗。
> **说明:**
>
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```
```
js
import
inputMethod
from
'
@ohos.inputmethod
'
;
```
##
inputMethod<sup>6+</sup>
##
常量
常量值。
**系统能力**
:以下各项对应的系统能力均为SystemCapability.Miscservices.InputMethodFramework
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| MAX_TYPE_NUM | number | 是 | 否 | 可支持的最大输入法个数。 |
**系统能力:**
SystemCapability.Miscservices.InputMethodFramework
| 名称 | 参数类型 | 常量值 | 说明 |
| -------- | -------- | ---------- | -------- |
| MAX_TYPE_NUM | number | 128 | 可支持的最大输入法个数。 |
## InputMethodProperty
<sup>6+</sup>
## InputMethodProperty
输入法应用属性。
**系统能力
**
:以下各项对应的系统能力均为
SystemCapability.Miscservices.InputMethodFramework
**系统能力
:**
SystemCapability.Miscservices.InputMethodFramework
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| packageName | string | 是 | 否 | 包名。 |
| methodId | string | 是 | 否 |
Ability名
。 |
| packageName | string | 是 | 否 |
输入法
包名。 |
| methodId | string | 是 | 否 |
输入法唯一标识
。 |
## inputMethod.getInputMethodController
getInputMethodController(): InputMethodController
获取客户端实例
[
InputMethodController
](
#
InputMethodC
ontroller
)
。
获取客户端实例
[
InputMethodController
](
#
inputmethodc
ontroller
)
。
**系统能力
**
:
SystemCapability.Miscservices.InputMethodFramework
**系统能力
:**
SystemCapability.Miscservices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| [InputMethodController](#InputMethodController) | 回调
返回当前客户端实例。 |
| 类型 | 说明 |
| -------- | -------- |
|
[
InputMethodController
](
#inputmethodcontroller
)
|
返回当前客户端实例。 |
**示例:**
```
js
var
I
nputMethodController
=
inputMethod
.
getInputMethodController
();
let
i
nputMethodController
=
inputMethod
.
getInputMethodController
();
```
## inputMethod.getInputMethodSetting
<sup>6+</sup>
## inputMethod.getInputMethodSetting
getInputMethodSetting(): InputMethodSetting
获取客户端设置实例
[
InputMethodSetting
](
#
InputMethodS
etting
)
。
获取客户端设置实例
[
InputMethodSetting
](
#
inputmethods
etting
)
。
**系统能力
**
:
SystemCapability.Miscservices.InputMethodFramework
**系统能力
:**
SystemCapability.Miscservices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| ----------------------------------------- | ---------------------------- |
|
[
InputMethodSetting
](
#InputMethodSetting
)
| 回调返回当前客户端设置实例。 |
| 类型 | 说明 |
| ----------------------------------------- | ------------------------ |
|
[
InputMethodSetting
](
#inputmethodsetting
)
| 返回当前客户端设置实例。 |
**示例:**
```
js
var
I
nputMethodSetting
=
inputMethod
.
getInputMethodSetting
();
let
i
nputMethodSetting
=
inputMethod
.
getInputMethodSetting
();
```
## InputMethodController
下列API示例中都需使用
[
getInputMethodController
](
#
getInputMethodC
ontroller
)
回调获取到InputMethodController实例,再通过此实例调用对应方法。
下列API示例中都需使用
[
getInputMethodController
](
#
inputmethodgetinputmethodc
ontroller
)
回调获取到InputMethodController实例,再通过此实例调用对应方法。
### stopInput
stopInput(callback: AsyncCallback
<
boolean
>
): void
隐藏输入法
。
结束输入法会话。使用callback异步回调
。
**系统能力
**
:
SystemCapability.Miscservices.InputMethodFramework
**系统能力
:**
SystemCapability.Miscservices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
boolean
>
| 是 |
返回输入法隐藏是否成功
。 |
| callback | AsyncCallback
<
boolean
>
| 是 |
回调函数,返回结束输入法会话是否成功的结果。true表示结束输入法会话成功;false表示结束输入法会话失败
。 |
**示例:**
```
js
InputMethodController
.
stopInput
((
error
)
=>
{
console
.
info
(
'
stopInput
'
);
});
inputMethodController
.
stopInput
((
error
,
result
)
=>
{
if
(
error
)
{
console
.
error
(
'
Failed to stop inputmethod session:
'
+
JSON
.
stringify
(
error
));
return
;
}
if
(
result
)
{
console
.
info
(
'
Succeeded in stopping inputmethod session.
'
);
}
else
{
console
.
error
(
'
Failed to stop inputmethod session.
'
);
}
});
```
### stopInput
stopInput(): Promise
<
boolean
>
隐藏输入法
。
结束输入法会话。使用Promise异步回调
。
**系统能力
**
:
SystemCapability.Miscservices.InputMethodFramework
**系统能力
:**
SystemCapability.Miscservices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
boolean
>
|
返回输入法隐藏是否成功
。 |
| Promise
<
boolean
>
|
Promise对象,返回结束输入法会话是否成功的结果。true表示结束输入法会话成功;false表示结束输入法会话失败
。 |
**示例:**
```
js
var
isSuccess
=
InputMethodController
.
stopInput
();
console
.
info
(
'
stopInput isSuccess =
'
+
isSuccess
);
inputMethodController
.
stopInput
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Succeeded in stopping inputmethod session.
'
);
}
else
{
console
.
error
(
'
Failed to stop inputmethod session
'
);
}
})
```
## InputMethodSetting
<sup>6+</sup>
## InputMethodSetting
下列API示例中都需使用
[
getInputMethodSetting
](
#
getInputMethodS
etting
)
回调获取到InputMethodSetting实例,再通过此实例调用对应方法。
下列API示例中都需使用
[
getInputMethodSetting
](
#
inputmethodgetinputmethods
etting
)
回调获取到InputMethodSetting实例,再通过此实例调用对应方法。
### listInputMethod
listInputMethod(callback: AsyncCallback
<
Array
<
InputMethodProperty
>>
): void
查询已安装的输入法列表。
查询已安装的输入法列表。
使用callback异步回调。
**系统能力
**
:
SystemCapability.Miscservices.InputMethodFramework
**系统能力
:**
SystemCapability.Miscservices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------------- | ---- | ---------------------- |
| callback | Array
<
[
InputMethodProperty
](
#
InputMethodProperty
)
>
| 是 | 返回已安装
输入法列表。 |
| callback | Array
<
[
InputMethodProperty
](
#
inputmethodproperty
)
>
| 是 | 回调函数,返回已安装的
输入法列表。 |
**示例:**
```
js
InputMethodSetting
.
listInputMethod
((
properties
)
=>
{
for
(
var
i
=
0
;
i
<
properties
.
length
;
i
++
)
{
var
property
=
properties
[
i
]
;
console
.
info
(
property
.
packageName
+
"
/
"
+
property
.
methodId
)
;
inputMethodSetting
.
listInputMethod
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to list inputmethods:
'
+
JSON
.
stringify
(
err
))
;
return
;
}
});
console
.
log
(
'
Succeeded in listing inputmethods, data:
'
+
JSON
.
stringify
(
data
));
});
```
### listInputMethod
listInputMethod(): Promise
<
Array
<
InputMethodProperty
>>
查询已安装的输入法列表。
查询已安装的输入法列表。
使用Promise异步回调。
**系统能力
**
:
SystemCapability.Miscservices.InputMethodFramework
**系统能力
:**
SystemCapability.Miscservices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------------------- | ---------------------- |
| Promise
<Array
<[
InputMethodProperty
](
#
InputMethodProperty
)
>
> | 返回已安装输入法列表。
|
| Promise
<Array
<[
InputMethodProperty
](
#
inputmethodproperty
)
>
> | Promise对象,返回已安装的输入法列表。
|
**示例:**
```
js
var
properties
=
InputMethodSetting
.
listInputMethod
();
for
(
var
i
=
0
;
i
<
properties
.
length
;
i
++
)
{
var
property
=
properties
[
i
];
console
.
info
(
property
.
packageName
+
"
/
"
+
property
.
methodId
);
}
inputMethodSetting
.
listInputMethod
().
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in listing inputMethod.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to list inputMethod:
'
+
JSON
.
stringify
(
err
)
);
})
```
### displayOptionalInputMethod
displayOptionalInputMethod(callback: AsyncCallback
<
void
>
): void
显示
输入法选择对话框
。
显示
选择输入法弹窗。使用callback异步回调
。
**系统能力
**
:
SystemCapability.Miscservices.InputMethodFramework
**系统能力
:**
SystemCapability.Miscservices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。
当选择输入法弹窗显示成功。err为undefined,否则为错误对象。
|
**示例:**
```
js
InputMethodSetting
.
displayOptionalInputMethod
(()
=>
{
console
.
info
(
'
displayOptionalInputMethod is called
'
);
});
inputMethodSetting
.
displayOptionalInputMethod
((
err
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to display optionalInputMethod:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in displaying optionalInputMethod.
'
);
});
```
### displayOptionalInputMethod
displayOptionalInputMethod(): Promise
<
void
>
displayOptionalInputMethod(): Promise
<
void
>
显示输入法选择对话框
。
显示选择输入法弹窗。使用Promise异步回调
。
**系统能力**
:
SystemCapability.Miscservices.InputMethodFramework
**系统能力:**
SystemCapability.Miscservices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
void
>
|
回调函数
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
```
js
InputMethodSetting
.
displayOptionalInputMethod
();
inputMethodSetting
.
displayOptionalInputMethod
().
then
(()
=>
{
console
.
info
(
'
Succeeded in displaying optionalInputMethod.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to display optionalInputMethod:
'
+
JSON
.
stringify
(
err
));
})
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录