From 1e0edb3f7c6ed7c768044eb57c39daefa707999c Mon Sep 17 00:00:00 2001 From: mayunteng_1 Date: Fri, 18 Nov 2022 16:41:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B3=87=E6=96=99=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mayunteng_1 Change-Id: I3fee1931ddccb843b20a5d6e4003f828abe83f46 --- .../reference/apis/js-apis-cooperate.md | 20 ++++++++++++------- .../reference/apis/js-apis-inputdevice.md | 14 ++++++------- .../apis/js-apis-inputeventclient.md | 4 ++-- .../reference/apis/js-apis-inputmonitor.md | 2 +- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-cooperate.md b/zh-cn/application-dev/reference/apis/js-apis-cooperate.md index dc0a2d3409..c3974d3863 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-cooperate.md +++ b/zh-cn/application-dev/reference/apis/js-apis-cooperate.md @@ -112,6 +112,8 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCal **示例**: ```js +let sinkDeviceDescriptor = "descriptor"; +let srcInputDeviceId = 0; try { inputDeviceCooperate.start(sinkDeviceDescriptor, srcInputDeviceId, (error) => { if (error) { @@ -160,6 +162,8 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise\ **示例**: ```js +let sinkDeviceDescriptor = "descriptor"; +let srcInputDeviceId = 0; try { inputDeviceCooperate.start(sinkDeviceDescriptor, srcInputDeviceId).then(() => { console.log(`Start Keyboard mouse crossing success.`); @@ -215,7 +219,7 @@ stop(): Promise\ | 参数名 | 说明 | | -------- | ---------------------------- | -| Promise\ | Promise对象,异步返回停止键鼠穿越结果。 | +| Promise\ | Promise对象,异步返回停止键鼠穿越结果。 | **示例**: @@ -249,6 +253,7 @@ getState(deviceDescriptor: string, callback: AsyncCallback<{ state: boolean }>): **示例**: ```js +let deviceDescriptor = "descriptor"; try { inputDeviceCooperate.getState(deviceDescriptor, (error, data) => { if (error) { @@ -289,6 +294,7 @@ getState(deviceDescriptor: string): Promise<{ state: boolean }> **示例**: ```js +let deviceDescriptor = "descriptor"; try { inputDeviceCooperate.getState(deviceDescriptor).then((data) => { console.log(`Get the status success, data: ${JSON.stringify(data)}`); @@ -324,7 +330,7 @@ try { inputDeviceCooperate.on('cooperation', (data) => { console.log(`Keyboard mouse crossing event: ${JSON.stringify(data)}`); }); -} catch (err) { +} catch (error) { console.log(`Register failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -350,25 +356,25 @@ off(type: 'cooperation', callback?: AsyncCallback\): void ```js // 取消注册单个回调函数 -callback: function(event) { +function callback(event) { console.log(`Keyboard mouse crossing event: ${JSON.stringify(event)}`); return false; }, try { - inputDeviceCooperate.on('cooperation', this.callback); - inputDeviceCooperate.off("cooperation", this.callback); + inputDeviceCooperate.on('cooperation', callback); + inputDeviceCooperate.off("cooperation", callback); } catch (error) { console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` ```js // 取消注册所有回调函数 -callback: function(event) { +function callback(event) { console.log(`Keyboard mouse crossing event: ${JSON.stringify(event)}`); return false; }, try { - inputDeviceCooperate.on('cooperation', this.callback); + inputDeviceCooperate.on('cooperation', callback); inputDeviceCooperate.off("cooperation"); } catch (error) { console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md index ecd2d4b196..6ad7b9bf7a 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @@ -334,19 +334,19 @@ inputDevice.getDeviceInfo(1).then((deviceData) => { ## inputDevice.supportKeys9+ -supportKeys(deviceId: number, keys: Array<KeyCode>, callback: Callback<Array<boolean>>): void +supportKeys(deviceId: number, keys: Array<KeyCode>, callback: AsyncCallback <Array<boolean>>): void -获取输入设备是否支持指定的键码值,使用Callback异步方式返回结果。 +获取输入设备是否支持指定的键码值,使用AsyncCallback异步方式返回结果。 **系统能力**:SystemCapability.MultimodalInput.Input.InputDevice **参数**: -| 参数 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------ | ---- | ------------------------------------------------------ | -| deviceId | number | 是 | 输入设备id,同一个物理设备反复插拔,设备id会发生变化。 | -| keys | Array<KeyCode> | 是 | 需要查询的键码值,最多支持5个按键查询。 | -| callback | Callback<Array<boolean>> | 是 | 回调函数,异步返回查询结果。 | +| 参数 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------- | ---- | ------------------------------------------------------ | +| deviceId | number | 是 | 输入设备id,同一个物理设备反复插拔,设备id会发生变化。 | +| keys | Array<KeyCode> | 是 | 需要查询的键码值,最多支持5个按键查询。 | +| callback | AsyncCallback<Array<boolean>> | 是 | 回调函数,异步返回查询结果。 | **示例**: diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md b/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md index 80d1a26688..d23d842670 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md @@ -41,7 +41,7 @@ try { keyDownDuration: 0, isIntercepted: false } - inputEventClient.injectKeyEvent({ KeyEvent: backKeyDown }); + inputEventClient.injectEvent({ KeyEvent: backKeyDown }); let backKeyUp = { isPressed: false, @@ -49,7 +49,7 @@ try { keyDownDuration: 0, isIntercepted: false }; - inputEventClient.injectKeyEvent({ KeyEvent: backKeyUp }); + inputEventClient.injectEvent({ KeyEvent: backKeyUp }); } catch (error) { console.log(`Failed to inject KeyEvent, error: ${JSON.stringify(error, [`code`, `message`])}`); } diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md index 242b63a32a..85716542e2 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md @@ -194,7 +194,7 @@ try { ```js try { inputMonitor.on("touch", touchEvent => { - if (touchEvent.touches.size() == 3) { // 当前有三个手指按下 + if (touchEvent.touches.length == 3) { // 当前有三个手指按下 return true; } else { return false; -- GitLab