Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
13c2d9bb
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看板
未验证
提交
13c2d9bb
编写于
5月 09, 2023
作者:
O
openharmony_ci
提交者:
Gitee
5月 09, 2023
浏览文件
操作
浏览文件
下载
差异文件
!17937 【输入法框架】【需求】监听显示隐藏输入法窗口事件
Merge pull request !17937 from Hollokin/master
上级
1d5cca22
bb7f981c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
67 addition
and
5 deletion
+67
-5
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
+67
-5
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
浏览文件 @
13c2d9bb
...
...
@@ -37,7 +37,7 @@ import inputMethod from '@ohos.inputMethod';
| labelId
<sup>
10+
</sup>
| string | 是 | 否 | 非必填。输入法对外显示名称资源号。|
| icon
<sup>
9+
</sup>
| string | 是 | 否 | 非必填。输入法图标数据。|
| iconId
<sup>
9+
</sup>
| number | 是 | 否 | 非必填。输入法图标资源号。 |
| extra
<sup>
10+
</sup>
| object | 是 | 是 | 非必填。输入法扩展信息
。|
| extra
<sup>
9+
</sup>
| object | 是 | 是 | 输入法扩展信息。
<br/>
- API version 10起:非必填;
<br/>
- API version 9:必填
。|
| 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替代。 |
...
...
@@ -212,13 +212,13 @@ getCurrentInputMethod(): InputMethodProperty
let
currentIme
=
inputMethod
.
getCurrentInputMethod
();
```
## inputMethod.switchCurrentInputMethodSubtype<sup>
10
+</sup>
## inputMethod.switchCurrentInputMethodSubtype<sup>
9
+</sup>
switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallback
\<
boolean>): void
在当前输入法应用内切换子类型。使用callback异步回调。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
,仅系统应用可用。
<br/>
**说明:**
从API version 10开始,如果调用者为当前输入法应用,则不需要此权限
。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
<br/>
**说明:**
<br/>
- API version 10起,允许系统应用及当前输入法应用调用;
<br/>
- API version 9,仅系统应用可用
。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -268,13 +268,13 @@ try {
}
```
## inputMethod.switchCurrentInputMethodSubtype<sup>
10
+</sup>
## inputMethod.switchCurrentInputMethodSubtype<sup>
9
+</sup>
switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise
<
boolean
>
在当前输入法应用内切换子类型。使用promise异步回调。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
,仅系统应用可用。
<br/>
**说明:**
从API version 10开始,如果调用者为当前输入法应用,则不需要此权限
。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
<br/>
**说明:**
<br/>
- API version 10起,允许系统应用及当前输入法应用调用;
<br/>
- API version 9,仅系统应用可用
。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -634,6 +634,20 @@ let inputMethodSetting = inputMethod.getInputMethodSetting();
| -------- | -------- | -------- | -------- | -------- |
| direction |
[
Direction
](
#direction10
)
| 是 | 是 | 进行选中文本动作时光标移动的方向。|
## InputWindowInfo<sup>10+</sup>
输入法软键盘的窗口信息。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| name | string | 是 | 是 | 输入法窗口的名称。|
| left | number | 是 | 是 | 输入法窗口左上顶点的横坐标,单位为px。|
| top | number | 是 | 是 | 输入法窗口左上顶点的纵坐标,单位为px。|
| width | number | 是 | 是 | 输入法窗口的宽度,单位为px。|
| height | number | 是 | 是 | 输入法窗口的高度,单位为px。|
## InputMethodController
下列API示例中都需使用
[
getController
](
#inputmethodgetcontroller9
)
获取到InputMethodController实例,再通过此实例调用对应方法。
...
...
@@ -2096,6 +2110,54 @@ off(type: 'imeChange', callback?: (inputMethodProperty: InputMethodProperty, inp
inputMethodSetting
.
off
(
'
imeChange
'
);
```
### on('imeShow'|'imeHide')<sup>10+</sup>
on(type: 'imeShow'|'imeHide', callback: (info: Array
\<
InputWindowInfo>) => void): void
订阅输入法软键盘显示或隐藏事件。使用callback异步回调。
**系统接口**
:此接口为系统接口。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---- | ---- | ---- |
| type | string | 是 | 设置监听类型。
<br/>
- type为
`imeShow`
时表示订阅输入法软键盘显示事件。
<br/>
- type为
`imeHide`
时表示订阅输入法软键盘隐藏事件。 |
| callback | (info: Array
\<
InputWindowInfo>) => void | 是 | 回调函数,返回输入法软键盘信息。 |
**示例:**
```
js
inputMethodSetting
.
on
(
'
imeShow
'
,
(
info
)
=>
{
console
.
info
(
'
Succeeded in subscribing imeShow event.
'
);
});
```
### off('imeShow'|'imeHide')<sup>10+</sup>
off(type: 'imeShow'|'imeHide', callback?: (info: Array
\<
InputWindowInfo>) => void): void
取消订阅输入法软键盘显示或隐藏事件。
**系统接口**
:此接口为系统接口。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---- | ---- | ------ |
| type | string | 是 | 设置监听类型。
<br/>
- type为
`imeShow`
时表示取消订阅输入法软键盘显示事件。
<br/>
- type为
`imeHide`
时表示取消订阅输入法软键盘隐藏事件。 |
| callback | (info: Array
\<
InputWindowInfo>) => void | 否 | 取消订阅的回调函数。当该参数不填写时,取消订阅type对应的所有回调事件。 |
**示例:**
```
js
inputMethodSetting
.
off
(
'
imeShow
'
);
```
### listInputMethodSubtype<sup>9+</sup>
listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: AsyncCallback
<
Array
<
InputMethodSubtype
>>
): void
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录