Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
11be4f73
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看板
提交
11be4f73
编写于
2月 07, 2023
作者:
Z
zhaolinglan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add doc
Signed-off-by:
N
zhaolinglan
<
zhaolinglan@huawei.com
>
上级
0fe24666
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
292 addition
and
0 deletion
+292
-0
zh-cn/application-dev/reference/apis/js-apis-inputmethod-InputMethodCommon.md
...v/reference/apis/js-apis-inputmethod-InputMethodCommon.md
+40
-0
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
+86
-0
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
...plication-dev/reference/apis/js-apis-inputmethodengine.md
+166
-0
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inputmethod-InputMethodCommon.md
0 → 100644
浏览文件 @
11be4f73
# InputMethodCommon
> **说明:**
> 本模块首批接口从API version 10 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
输入法框架接口定义的公共属性信息。
## MediaType<sup>8+</sup>
光标移动方向类型枚举。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 值 | 说明 |
| ------------ | ---- | ---------- |
| CURSOR_UP | 1 | 光标上移。 |
| CURSOR_DOWN | 2 | 光标下移。 |
| CURSOR_LEFT | 3 | 光标左移。 |
| CURSOR_RIGHT | 4 | 光标右移。 |
## Range
描述选中文本的范围
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ----- | ------ | ---- | ---- | ---------------------------------- |
| start | string | 是 | 是 | 选中文本的首字符在编辑框的索引值。 |
| end | string | 是 | 是 | 选中文本的末字符在编辑框的索引值。 |
## Movement
描述进行选中文本动作时光标移动的方向。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------- | --------- | ---- | ---- | ---------------------------------- |
| direction | Direction | 是 | 是 | 进行选中文本动作时光标移动的方向。 |
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
浏览文件 @
11be4f73
...
@@ -839,6 +839,92 @@ inputMethodController.stopInput().then((result) => {
...
@@ -839,6 +839,92 @@ inputMethodController.stopInput().then((result) => {
})
})
```
```
### on('selectByRange')<sup>10+</sup>
on(type: 'selectByRange', callback: Callback
<
Range
>
): void
订阅输入法应用按范围选中文本事件。使用callback异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
-type为‘selectByRange’时表示订阅输入法应用按范围选中文本事件监听。 |
| callback | Callback
<
Range
>
| 是 | 回调函数,返回需要选中的文本的范围。
<br/>
开发者需要在回调函数中根据传入的范围选中编辑框中相应文本。 |
**示例:**
```
js
inputMethodController
.
on
(
'
selectByRange
'
,
(
range
)
=>
{
console
.
info
(
'
Succeeded in subscribing selectByRange: start:
'
+
range
.
start
+
"
, end:
"
+
range
.
end
);
});
```
### off('selectByRange')<sup>10+</sup>
off(type: 'selectByRange'): void
取消订阅输入法应用按范围选中文本事件。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
-type为‘selectByRange’时表示取消订阅输入法应用按范围选中文本事件监听。 |
**示例:**
```
js
inputMethodController
.
off
(
'
selectByRange
'
);
```
### on('selectByMovement')<sup>10+</sup>
on(type: 'selectByMovement', callback: Callback
<
Range
>
): void
订阅输入法应用按光标动作选中文本事件。使用callback异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
-type为‘selectByMovement’时表示订阅输入法应用按光标移动动作选中文本事件监听。 |
| callback | Callback
<
Movement
>
| 是 | 回调函数,返回需要选中的文本的范围。
<br/>
开发者需要在回调函数中根据传入的光标动作选中编辑框中相应文本。 |
**示例:**
```
js
inputMethodController
.
on
(
'
selectByMovement
'
,
(
movement
)
=>
{
console
.
info
(
'
Succeeded in subscribing selectByMovement: direction:
'
+
movement
.
direction
);
});
```
### off('selectByMovement')<sup>10+</sup>
off(type: 'selectByMovement'): void
取消订阅输入法应用按光标动作选中文本事件。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
-type为‘selectByMovement’时表示取消订阅输入法应用按范围选中文本事件监听。 |
**示例:**
```
js
inputMethodController
.
off
(
'
selectByMovement
'
);
```
## InputMethodSetting<sup>8+</sup>
## InputMethodSetting<sup>8+</sup>
下列API示例中都需使用
[
getSetting
](
#inputmethodgetsetting9
)
获取到InputMethodSetting实例,再通过此实例调用对应方法。
下列API示例中都需使用
[
getSetting
](
#inputmethodgetsetting9
)
获取到InputMethodSetting实例,再通过此实例调用对应方法。
...
...
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
浏览文件 @
11be4f73
...
@@ -1495,6 +1495,172 @@ try {
...
@@ -1495,6 +1495,172 @@ try {
}
}
```
```
### selectByRange<sup>10+</sup>
selectByRange(range: Range, callback: AsyncCallback
<
void
>
): void
根据索引范围选中文本。使用callback异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| range | Range | 是 | 选中文本的范围。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当成功发送选中事件后,err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------- |
| 401 | parameter error. |
| 12800003 | Input method client error. |
**示例:**
```
js
try
{
inputClient
.
selectByRange
({
start
:
0
,
end
:
1
},
(
err
)
=>
{
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to selectByRange:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in selecting by range.
'
);
});
}
catch
(
err
)
{
console
.
error
(
'
Failed to selectByRange:
'
+
JSON
.
stringify
(
err
));
}
```
### selectByRange<sup>10+</sup>
selectByRange(range: Range): Promise
<
void
>
根据索引范围选中文本。使用promise异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----- | ---- | ---------------- |
| range | Range | 是 | 选中文本的范围。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------- |
| 401 | parameter error. |
| 12800003 | Input method client error. |
**示例:**
```
js
try
{
inputClient
.
selectByRange
({
start
:
0
,
end
:
1
}).
then
(()
=>
{
console
.
log
(
'
Succeeded in selecting by range.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to selectByRange:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
err
)
{
console
.
log
(
'
Failed to selectByRange:
'
+
JSON
.
stringify
(
err
));
}
```
### selectByMovement<sup>10+</sup>
selectByMovement(movement: Movement, callback: AsyncCallback
<
void
>
): void
根据光标移动方向选中文本。使用callback异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| movement | Movement | 是 | 选中时光标移动的方向。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当成功发送选中事件后,err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------- |
| 401 | parameter error. |
| 12800003 | Input method client error. |
**示例:**
```
js
try
{
inputClient
.
selectByMovement
({
direction
:
1
},
(
err
)
=>
{
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to selectByMovement:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in selecting by movement.
'
);
});
}
catch
(
err
)
{
console
.
error
(
'
Failed to selectByMovement:
'
+
JSON
.
stringify
(
err
));
}
```
### selectByMovement<sup>10+</sup>
selectByMovement(range: Range): Promise
<
void
>
根据索引范围选中文本。使用promise异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | ---- | ---------------------- |
| movement | Movement | 是 | 选中时光标移动的方向。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
输入法框架错误码
](
../errorcodes/errorcode-inputmethod-framework.md
)
。
| 错误码ID | 错误信息 |
| -------- | -------------------------- |
| 401 | parameter error. |
| 12800003 | Input method client error. |
**示例:**
```
js
try
{
inputClient
.
selectByMovement
({
direction
:
1
}).
then
(()
=>
{
console
.
log
(
'
Succeeded in selecting by movement.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to selectByMovement:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
err
)
{
console
.
log
(
'
Failed to selectByMovement:
'
+
JSON
.
stringify
(
err
));
}
```
## EditorAttribute
## EditorAttribute
编辑框属性值。
编辑框属性值。
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录