提交 d5352540 编写于 作者: M mayunteng_1

接口补充

Signed-off-by: Nmayunteng_1 <mayunteng@huawei.com>
Change-Id: Ic18572382fe80d575c8b107f1f887124838bae4f
上级 27173217
......@@ -159,6 +159,76 @@ export default {
## inputDevice.on
function on(type: "change", listener: Callback<DeviceListener>): void;
开始监听设备插拔事件。
**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice
**返回值:**
| 参数 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | -------- |
| type | string | 是 | 监听类型 |
| listener | Callback<DeviceListener> | 是 | 回调函数 |
**示例:**
```js
export default {
DeviceListener: {
type : "NA",
deviceId : 0
},
callback: function(deviceChangedData) {
this.DeviceListener = deviceChangedData;
},
testOn: function () {
// 示例监听设备插拔事件
console.info("InputDeviceJsTest---start---testOn");
inputDevice.on("change", this.callback);
console.info("InputDeviceJsTest---end---testOn");
}
}
```
## inputDevice.off
function off(type: "change", listener?: Callback<DeviceListener>): void;
停止监听设备插拔事件。
**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice
**返回值:**
| 参数 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | ------------------ |
| type | string | 是 | 监听类型 |
| listener | Callback<DeviceListener> | 否 | 停止监听的回调函数 |
**示例:**
```js
export default {
DeviceListener: {
type : "NA",
deviceId : 0
},
callback: function(deviceChangedData) {
this.DeviceListener = deviceChangedData;
},
testOff: function () {
// 示例监听设备插拔事件
console.info("InputDeviceJsTest---start---testOff");
inputDevice.off("change", this.callback);
console.info("InputDeviceJsTest---end---testOff");
}
}
```
## InputDeviceData
输入设备的描述信息。
......@@ -204,3 +274,14 @@ export default {
| trackball | string | 表示输入设备是轨迹球。 |
| touchpad | string | 表示输入设备是触摸板。 |
| joystick | string | 表示输入设备是操纵杆。 |
## DeviceListener
设备插拔事件。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| -------- | -------- | --------------------------------- |
| type | string | 表示设备插拔类型,取值add和remove |
| deviceId | number | 表示设备id |
\ No newline at end of file
......@@ -24,17 +24,17 @@ ohos.permission.INPUT_MONITORING
on(type: "touch", receiver: TouchEventReceiver): void
开始监听全局输入
开始监听全局触屏事件
**需要权限:**ohos.permission.INPUT_MONITORING
**系统能力:**SystemCapability.MultimodalInput.Input.InputMonitor
**参数:**
| 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | -------------------- |
| type | string | 是 | 监听输入事件类型,只支持“touch”。 |
| receiver | [TouchEventReceiver](#toucheventreceiver) | 是 | 触摸输入事件回调函数。 |
| 参数 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------- | ---- | ------------------------------- |
| type | string | 是 | 监听输入事件类型,取值“touch”。 |
| receiver | [TouchEventReceiver](#toucheventreceiver) | 是 | 触摸输入事件回调函数。 |
**示例:**
......@@ -60,22 +60,60 @@ export default {
}
```
on(type: "mouse", receiver: TouchEventReceiver): void
开始监听全局鼠标事件。
**需要权限:**ohos.permission.INPUT_MONITORING
**系统能力:**SystemCapability.MultimodalInput.Input.InputMonitor
**参数:**
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | -------------------------------------- |
| type | string | 是 | 监听输入事件类型,取值“mouse”。 |
| receiver | Callback<MouseEvent> | 是 | 鼠标输入事件回调函数。MouseEvent参考xx |
**示例:**
```
export default {
callback: function (value) {
if (checkEvent(value)) {
//事件满足业务要求,事件被消费
} else {
//事件不满足业务要求,事件未被消费
}
},
testOn: function () {
console.info("InputMonitorJsTest---start---testOn");
inputMonitor.on(
"mouse",
this.callback
);
console.info("InputMonitorJsTest---end---testOn");
}
}
```
## inputMonitor.off
off(type: "touch", receiver: TouchEventReceiver): void
停止监听全局输入
开始监听全局触屏事件
**需要权限:**ohos.permission.INPUT_MONITORING
**系统能力:**SystemCapability.MultimodalInput.Input.InputMonitor
**参数:**
| 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | -------------------- |
| type | string | 是 | 监听输入事件类型,只支持“touch”。 |
| receiver | [TouchEventReceiver](#toucheventreceiver) | 否 | 触摸输入事件回调函数。 |
| 参数 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------- | ---- | ------------------------------- |
| type | string | 是 | 监听输入事件类型,取值“touch”。 |
| receiver | [TouchEventReceiver](#toucheventreceiver) | 否 | 触摸输入事件回调函数。 |
**示例:**
......@@ -101,6 +139,44 @@ export default {
}
```
off(type: "mouse", receiver?: Callback<MouseEvent>): void
停止监听全局鼠标事件。
**需要权限:**ohos.permission.INPUT_MONITORING
**系统能力:**SystemCapability.MultimodalInput.Input.InputMonitor
**参数:**
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | -------------------------------------- |
| type | string | 是 | 监听输入事件类型,取值“mouse”。 |
| receiver | Callback<MouseEvent> | 否 | 触摸输入事件回调函数。MouseEvent参考xx |
**示例:**
```
export default {
callback: function (value) {
if (checkEvent(value)) {
//事件满足业务要求,事件被消费
} else {
//事件不满足业务要求,事件未被消费
}
},
testOff: function () {
console.info("InputMonitorJsTest---start---testOff");
inputMonitor.off(
"touch",
this.callback
);
console.info("InputMonitorJsTest---end---testOff");
}
}
```
## TouchEventReceiver
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册