Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
42c41f2b
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看板
提交
42c41f2b
编写于
6月 29, 2022
作者:
S
shaoziyun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
多模md文件修改
Signed-off-by:
N
shaoziyun
<
shaoziyun@huawei.com
>
上级
2c82300c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
109 addition
and
141 deletion
+109
-141
zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md
...n/application-dev/reference/apis/js-apis-inputconsumer.md
+21
-16
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
+45
-41
zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md
...pplication-dev/reference/apis/js-apis-inputeventclient.md
+10
-5
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md
+33
-79
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md
100644 → 100755
浏览文件 @
42c41f2b
# 组合按键
# 组合按键
InputConsumer模块提供对按键事件的监听。
>  **说明:**
>  **说明:**
>
>
...
@@ -22,23 +23,23 @@ on(type: "key", keyOptions: KeyOptions, callback: Callback<KeyOptions>): v
...
@@ -22,23 +23,23 @@ on(type: "key", keyOptions: KeyOptions, callback: Callback<KeyOptions>): v
开始监听组合按键事件, 当满足条件的组合按键输入事件发生时,将KeyOptions回调到入参callback表示的回调函数上。
开始监听组合按键事件, 当满足条件的组合按键输入事件发生时,将KeyOptions回调到入参callback表示的回调函数上。
**系统能力:**
SystemCapability.MultimodalInput.Input.InputConsumer
此接口为系统接口。
**参数:**
**参数:**
| 参数 | 类型 | 必填 | 说明 |
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 监听输入事件类型,只支持“key”。 |
| type | string | 是 | 监听输入事件类型,只支持“key”。 |
| keyOptions |
[
KeyOptions
](
#keyoption
)
| 是 | 组合键选项,用来指定组合键输入时应该符合的条件。 |
| keyOptions |
[
keyOptions
](
#keyOptions
)
| 是 | 组合键选项,用来指定组合键输入时应该符合的条件。 |
| callback | Callback
<
KeyOptions
>
| 是 | 回调函数。当满足条件的按键输入产生时,回调到此函数,以传入的
k
eyOptions为入参。 |
| callback | Callback
<
KeyOptions
>
| 是 | 回调函数。当满足条件的按键输入产生时,回调到此函数,以传入的
K
eyOptions为入参。 |
**示例:**
**示例:**
```
```
let keyOptions = {
preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0
}
let keyOptions = {
preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0
}
let callback = function
(keyOptions) {
let callback = function(keyOptions) {
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
}
}
inputConsumer.on('key', keyOptions, callback);
inputConsumer.on('key', keyOptions, callback);
```
```
...
@@ -46,10 +47,12 @@ inputConsumer.on('key', keyOptions, callback);
...
@@ -46,10 +47,12 @@ inputConsumer.on('key', keyOptions, callback);
## inputConsumer.off
## inputConsumer.off
off(type: "key", keyOptions: KeyOptions, callback: Callback
<
KeyOptions
>
): void
off(type: "key", keyOptions: KeyOptions, callback
?
: Callback
<
KeyOptions
>
): void
停止监听组合按键事件。
停止监听组合按键事件。
此接口为系统接口。
**系统能力:**
SystemCapability.MultimodalInput.Input.InputConsumer
**系统能力:**
SystemCapability.MultimodalInput.Input.InputConsumer
**参数:**
**参数:**
...
@@ -57,16 +60,16 @@ off(type: "key", keyOptions: KeyOptions, callback: Callback<KeyOptions>):
...
@@ -57,16 +60,16 @@ off(type: "key", keyOptions: KeyOptions, callback: Callback<KeyOptions>):
| 参数 | 类型 | 必填 | 说明 |
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 监听输入事件类型,只支持“key”。 |
| type | string | 是 | 监听输入事件类型,只支持“key”。 |
| keyOptions |
[
KeyOptions
](
#keyoption
)
| 是 | 开始监听时传入的K
eyOptions。 |
| keyOptions |
[
keyOptions
](
#keyOptions
)
| 是 | 开始监听时传入的k
eyOptions。 |
| callback | Callback
<
KeyOptions
>
| 是 | 开始监听时与KeyOption
s
一同传入的回调函数
。 |
| callback | Callback
<
KeyOptions
>
| 是 | 开始监听时与KeyOption一同传入的回调函数
。 |
**示例:**
**示例:**
```
```
let keyOptions = {
preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0
}
let keyOptions = {
preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0
}
let callback = function
(keyOptions) {
let callback = function(keyOptions) {
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
}
}
inputConsumer.off('key', keyOptions, callback);
inputConsumer.off('key', keyOptions, callback);
```
```
...
@@ -76,9 +79,11 @@ inputConsumer.off('key', keyOptions, callback);
...
@@ -76,9 +79,11 @@ inputConsumer.off('key', keyOptions, callback);
组合键输入事件发生时,组合键满足的选项。
组合键输入事件发生时,组合键满足的选项。
**系统能力:**
以下各项对应系统能力均为SystemCapability.MultimodalInput.Input.InputConsumer
此接口为系统接口。
| 参数 | 类型 | 必填 | 说明 |
**系统能力:**
SystemCapability.MultimodalInput.Input.InputConsumer
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| preKeys | Array | 是 | 组合键前置按键集合,可为空,前置按键无顺序要求。 |
| preKeys | Array | 是 | 组合键前置按键集合,可为空,前置按键无顺序要求。 |
| finalKey | Number | 是 | 组合键最后按键,不能为空。 |
| finalKey | Number | 是 | 组合键最后按键,不能为空。 |
...
...
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
100644 → 100755
浏览文件 @
42c41f2b
...
@@ -4,8 +4,7 @@
...
@@ -4,8 +4,7 @@
输入设备管理模块,用于监听输入设备连接、断开和变化,并查看输入设备相关信息。比如监听鼠标插拔,并获取鼠标的id、name和指针移动速度等信息。
输入设备管理模块,用于监听输入设备连接、断开和变化,并查看输入设备相关信息。比如监听鼠标插拔,并获取鼠标的id、name和指针移动速度等信息。
> **说明:**
> **说明**:<br>
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...
@@ -23,16 +22,15 @@ getDeviceIds(callback: AsyncCallback<Array<number>>): void
...
@@ -23,16 +22,15 @@ getDeviceIds(callback: AsyncCallback<Array<number>>): void
获取所有输入设备的id列表,使用callback方式作为异步方法。
获取所有输入设备的id列表,使用callback方式作为异步方法。
**系统能力
:**
SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
SystemCapability.MultimodalInput.Input.InputDevice
**参数
:**
**参数
**
:
| 参数 | 类型 | 必填 | 说明 |
| 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ----- |
| -------- | ---------------------------------------- | ---- | ----- |
| callback | AsyncCallback
<
Array
<
number
>>
| 是 | 回调函数。 |
| callback | AsyncCallback
<
Array
<
number
>>
| 是 | 回调函数。 |
**示例**
:
**示例:**
```
js
```
js
inputDevice
.
getDeviceIds
((
ids
)
=>
{
inputDevice
.
getDeviceIds
((
ids
)
=>
{
...
@@ -42,19 +40,19 @@ inputDevice.getDeviceIds((ids)=>{
...
@@ -42,19 +40,19 @@ inputDevice.getDeviceIds((ids)=>{
## inputDevice.getDeviceIds
## inputDevice.getDeviceIds
function getDeviceIds(): Promise
<Array
\<
number
>
>
getDeviceIds(): Promise
<
Array
<
number
>>
获取所有输入设备的id列表,使用Promise方式作为异步方法。
获取所有输入设备的id列表,使用Promise方式作为异步方法。
**系统能力
:**
SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
SystemCapability.MultimodalInput.Input.InputDevice
**返回值
:**
**返回值
**
:
| 参数
| 说明
|
| 参数
| 说明
|
| ------------------------
|
------------------ |
| ------------------------
---------- | -
------------------ |
| Promise
\<
Array
\<
number>> | Promise实例,用于异步获取结果
|
| Promise
<
Array
<
number
>>
| Promise实例,用于异步获取结果。
|
**示例
:**
**示例
**
:
```
js
```
js
inputDevice
.
getDeviceIds
().
then
((
ids
)
=>
{
inputDevice
.
getDeviceIds
().
then
((
ids
)
=>
{
...
@@ -68,16 +66,16 @@ getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): voi
...
@@ -68,16 +66,16 @@ getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): voi
获取输入设备的描述信息,使用callback方式作为异步方法。
获取输入设备的描述信息,使用callback方式作为异步方法。
**系统能力
:**
SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
SystemCapability.MultimodalInput.Input.InputDevice
**参数
:**
**参数
**
:
| 参数 | 类型 | 必填 | 说明 |
| 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | --------------------------- |
| -------- | ---------------------------------------- | ---- | --------------------------- |
| deviceId | number | 是 | 需要获取信息的设备id。 |
| deviceId | number | 是 | 需要获取信息的设备id。 |
| callback | AsyncCallback
<
[InputDeviceData](#inputdevicedata)
>
| 是 | 回调函数,异步返回InputDeviceData对象。 |
| callback | AsyncCallback
<
[InputDeviceData](#inputdevicedata)
>
| 是 | 回调函数,异步返回InputDeviceData对象。 |
**示例
:**
**示例
**
:
```
js
```
js
// 示例获取设备id为1的设备name信息。
// 示例获取设备id为1的设备name信息。
...
@@ -88,19 +86,25 @@ inputDevice.getDevice(1, (inputDevice)=>{
...
@@ -88,19 +86,25 @@ inputDevice.getDevice(1, (inputDevice)=>{
## inputDevice.getDevice
## inputDevice.getDevice
function getDevice(deviceId: number): Promise
\<
InputDeviceData>
getDevice(deviceId: number): Promise
<
InputDeviceData
>
获取输入设备的描述信息,使用Promise方式作为异步方法。
获取输入设备的描述信息,使用Promise方式作为异步方法。
**系统能力:**
SystemCapability.MultimodalInput.Input.InputDevice
**系统能力**
:SystemCapability.MultimodalInput.Input.InputDevice
**参数**
:
| 参数 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------ |
| deviceId | number | 是 | 需要获取信息的设备id。 |
**返回值
:**
**返回值
**
:
| 参数
| 说明
|
| 参数
| 说明
|
| -------------------------
|
------------------ |
| -------------------------
--------------- | -
------------------ |
| Promise
\<
InputDeviceData> | Promise实例,用于异步获取结果
|
| Promise
<
[InputDeviceData](#inputdevicedata)
>
| Promise实例,用于异步获取结果。
|
**示例
:**
**示例
**
:
```
js
```
js
// 示例获取设备id为1的设备name信息。
// 示例获取设备id为1的设备name信息。
...
@@ -115,30 +119,30 @@ inputDevice.getDevice(1).then((inputDevice)=>{
...
@@ -115,30 +119,30 @@ inputDevice.getDevice(1).then((inputDevice)=>{
输入设备的描述信息。
输入设备的描述信息。
**系统能力
:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| 名称
| 参数类型 | 说明 |
| ---------- | -------------------------------------- | ---------------------------------------- |
| ----------
----------
| -------------------------------------- | ---------------------------------------- |
| id | number | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| id
| number | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| name | string | 输入设备的名字。 |
| name
| string | 输入设备的名字。 |
| sources | Array
<
[SourceType](#sourcetype)
>
| 输入设备支持的源类型。比如有的键盘上附带触摸板,则此设备有keyboard和touchpad两种输入源。 |
| sources
| Array
<
[SourceType](#sourcetype)
>
| 输入设备支持的源类型。比如有的键盘上附带触摸板,则此设备有keyboard和touchpad两种输入源。 |
| axisRanges | Array
<
[axisRanges](#axisrange)
>
| 输入设备的轴信息。 |
| axisRanges
| Array
<
[axisRanges](#axisrange)
>
| 输入设备的轴信息。 |
| bus
| number | 输入设备的总线类型。 |
| bus
<sup>
9+
</sup>
| number | 输入设备的总线类型。 |
| product
| number | 输入设备的产品信息。 |
| product
<sup>
9+
</sup>
| number | 输入设备的产品信息。 |
| vendor
| number | 输入设备的厂商信息。 |
| vendor
<sup>
9+
</sup>
| number | 输入设备的厂商信息。 |
| version
| number | 输入设备的版本信息。 |
| version
<sup>
9+
</sup>
| number | 输入设备的版本信息。 |
| phys
| string | 输入设备的物理地址。 |
| phys
<sup>
9+
</sup>
| string | 输入设备的物理地址。 |
| uniq
| string | 输入设备的唯一标识。 |
| uniq
<sup>
9+
</sup>
| string | 输入设备的唯一标识。 |
## AxisType
## AxisType
<sup>9+</sup>
输入设备的轴类型
,为'Null'
。
输入设备的轴类型。
## AxisRange
## AxisRange
输入设备的轴信息。
输入设备的轴信息。
**系统能力
:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| 名称 | 参数类型 | 说明 |
| ------ | ------------------------- | -------- |
| ------ | ------------------------- | -------- |
...
@@ -151,9 +155,9 @@ inputDevice.getDevice(1).then((inputDevice)=>{
...
@@ -151,9 +155,9 @@ inputDevice.getDevice(1).then((inputDevice)=>{
## SourceType
## SourceType
定义轴的输入源类型。比如鼠标设备可上报x轴事件,则x轴的源就是鼠标。
定义
这个
轴的输入源类型。比如鼠标设备可上报x轴事件,则x轴的源就是鼠标。
**系统能力
:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| 名称 | 参数类型 | 说明 |
| ----------- | ------ | ----------- |
| ----------- | ------ | ----------- |
...
...
zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md
100644 → 100755
浏览文件 @
42c41f2b
# 注入按键
# 注入按键
InputEventClient模块提供了注入按键能力。
> **说明:**
> **说明:**
>
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
-
本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
>
> 本模块接口均为系统接口,三方应用不支持调用。
>
-
本模块接口均为系统接口,三方应用不支持调用。
## 导入模块
## 导入模块
...
@@ -22,6 +23,8 @@ injectEvent({KeyEvent: KeyEvent}): void
...
@@ -22,6 +23,8 @@ injectEvent({KeyEvent: KeyEvent}): void
注入按键,KeyEvent为注入按键的描述信息。
注入按键,KeyEvent为注入按键的描述信息。
此接口为系统接口。
**系统能力:**
SystemCapability.MultimodalInput.Input.InputSimulator
**系统能力:**
SystemCapability.MultimodalInput.Input.InputSimulator
**参数:**
**参数:**
...
@@ -47,11 +50,13 @@ let res = inputEventClient.injectEvent({KeyEvent: keyEvent});
...
@@ -47,11 +50,13 @@ let res = inputEventClient.injectEvent({KeyEvent: keyEvent});
注入按键的描述信息
注入按键的描述信息
此接口为系统接口。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputSimulator
**系统能力:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputSimulator
| 参数 | 类型 | 必填 | 说明 |
| 参数 | 类型 | 必填 | 说明 |
| --------------- | ------- | ---- | --------- |
| --------------- | ------- | ---- | --------- |
| isPressed | boolean | 是 | 按键是否按下 |
| isPressed | boolean | 是 | 按键是否按下 |
| keyCode |
N
umber | 是 | 按键键值 |
| keyCode |
n
umber | 是 | 按键键值 |
| keyDownDuration |
boolean
| 是 | 按键按下持续时间 |
| keyDownDuration |
number
| 是 | 按键按下持续时间 |
| isIntercepted |
Number
| 是 | 按键是否可以被拦截 |
| isIntercepted |
boolean
| 是 | 按键是否可以被拦截 |
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md
100644 → 100755
浏览文件 @
42c41f2b
# 输入监听
# 输入监听
InputMonitor模块提供了监听全局触摸事件的功能。
>  **说明:**
>  **说明:**
> - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...
@@ -10,7 +11,7 @@
...
@@ -10,7 +11,7 @@
## 导入模块
## 导入模块
```
```
js
import
inputMonitor
from
'
@ohos.multimodalInput.inputMonitor
'
;
import
inputMonitor
from
'
@ohos.multimodalInput.inputMonitor
'
;
```
```
...
@@ -24,92 +25,59 @@ ohos.permission.INPUT_MONITORING
...
@@ -24,92 +25,59 @@ ohos.permission.INPUT_MONITORING
on(type: "touch", receiver: TouchEventReceiver): void
on(type: "touch", receiver: TouchEventReceiver): void
开始监听全局输入。
开始监听全局触屏事件。
此接口为系统接口。
**需要权限:**
ohos.permission.INPUT_MONITORING
**需要权限:**
ohos.permission.INPUT_MONITORING
**系统能力:**
SystemCapability.MultimodalInput.Input.InputMonitor
**系统能力:**
SystemCapability.MultimodalInput.Input.InputMonitor
**参数:**
**参数:**
| 参数
| 类型 | 必填 | 说明
|
| 参数
| 类型 | 必填 | 说明
|
| -------- | ----------------------------------------
| ---- |
-------------------- |
| -------- | ----------------------------------------
- | ---- | -----------
-------------------- |
| type | string
| 是 | 监听输入事件类型,只支持
“touch”。 |
| type | string
| 是 | 监听输入事件类型,取值
“touch”。 |
| receiver |
[
TouchEventReceiver
](
#toucheventreceiver
)
| 是
| 触摸输入事件回调函数。 |
| receiver |
[
TouchEventReceiver
](
#toucheventreceiver
)
| 是 | 触摸输入事件回调函数。 |
**示例:**
**示例:**
```
```
js
export default {
inputMonitor
.
off
(
"
touch
"
,
(
event
)
=>
{
callback: function (value) {
// 消费触屏事件
if (checkEvent(value)) {
return
false
;
//事件满足业务要求,事件被消费
});
return true;
} else {
//事件不满足业务要求,事件未被消费
return false;
}
},
testOn: function () {
console.info("InputMonitorJsTest---start---testOn");
inputMonitor.on(
"touch",
this.callback
);
console.info("InputMonitorJsTest---end---testOn");
}
}
```
```
## inputMonitor.off
## inputMonitor.off
off(type: "touch", receiver?: TouchEventReceiver): void
off(type: "touch", receiver?: TouchEventReceiver): void
停止监听全局输入。
停止监听全局触屏事件。
此接口为系统接口。
**需要权限:**
ohos.permission.INPUT_MONITORING
**需要权限:**
ohos.permission.INPUT_MONITORING
**系统能力:**
SystemCapability.MultimodalInput.Input.InputMonitor
**系统能力:**
SystemCapability.MultimodalInput.Input.InputMonitor
**参数:**
**参数:**
| 参数
| 类型 | 必填 | 说明
|
| 参数
| 类型 | 必填 | 说明
|
| -------- | ----------------------------------------
| ---- |
-------------------- |
| -------- | ----------------------------------------
- | ---- | -----------
-------------------- |
| type | string
| 是 | 监听输入事件类型,只支持
“touch”。 |
| type | string
| 是 | 监听输入事件类型,取值
“touch”。 |
| receiver |
[
TouchEventReceiver
](
#toucheventreceiver
)
| 否
| 触摸输入事件回调函数。 |
| receiver |
[
TouchEventReceiver
](
#toucheventreceiver
)
| 否 | 触摸输入事件回调函数。 |
**示例:**
**示例:**
```
```
js
export default {
inputMonitor
.
off
(
"
touch
"
);
callback: function (value) {
if (checkEvent(value)) {
//事件满足业务要求,事件被消费
return true;
} else {
//事件不满足业务要求,事件未被消费
return false;
}
},
testOff: function () {
console.info("InputMonitorJsTest---start---testOff");
inputMonitor.off(
"touch",
this.callback
);
console.info("InputMonitorJsTest---end---testOff");
}
}
```
```
## TouchEventReceiver
## TouchEventReceiver
触摸输入事件的回调函数,如果返回true,则触摸输入将被监听器消耗(系统执行关闭动作)。
触摸输入事件的回调函数。如果返回true,则触摸输入被监听器消耗,系统将执行关闭动作。
### (touchEvent: TouchEvent): Boolean
此接口为系统接口。
触摸输入事件的回调函数。函数名由使用者定义,这里是函数调用时必须符合的格式,传入参数必须为TouchEvent类型,返回值为Boolean类型。
**系统能力:**
SystemCapability.MultimodalInput.Input.InputMonitor
**系统能力:**
SystemCapability.MultimodalInput.Input.InputMonitor
...
@@ -119,30 +87,16 @@ export default {
...
@@ -119,30 +87,16 @@ export default {
| touchEvent |
[
TouchEvent
](
../arkui-js/js-components-common-events.md
)
| 是 | 触摸输入事件回调函数,返回true表示输触事件被监听器消费,false表示输触事件未被监听器消费。 |
| touchEvent |
[
TouchEvent
](
../arkui-js/js-components-common-events.md
)
| 是 | 触摸输入事件回调函数,返回true表示输触事件被监听器消费,false表示输触事件未被监听器消费。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| ------- | -------------------------------------- |
| ------- | -------------------------------------- |
| Boolean | 返回true表示
输触事件被监听器消费,false表示输触
事件未被监听器消费。 |
| Boolean | 返回true表示
触摸输入事件被监听器消费,false表示触摸输入
事件未被监听器消费。 |
**示例:**
**示例:**
```
```
js
export default {
inputMonitor
.
on
(
"
touch
"
,
(
event
)
=>
{
callback: function (value) { //此处为(touchEvent:TouchEvent): Boolean 方法的实现
// 消费触摸输入事件
if (checkEvent(value)) {
return
false
;
//事件满足业务要求,事件被消费
});
return true;
inputMonitor
.
off
(
"
touch
"
);
} else {
//事件不满足业务要求,事件未被消费
return false;
}
},
testOff: function () {
console.info("InputMonitorJsTest---start---testOff");
inputMonitor.off(
"touch",
this.callback
);
console.info("InputMonitorJsTest---end---testOff");
}
}
```
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录