From 6caf5e29e8e9207249d877547ea0bc06e78c9ae0 Mon Sep 17 00:00:00 2001 From: mayunteng_1 Date: Thu, 10 Nov 2022 11:08:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A4=BA=E4=BE=8B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mayunteng_1 Change-Id: Idb4d94a261a4fefbb9a1bb323a3d177b7180a274 --- .../reference/apis/js-apis-inputconsumer.md | 15 +++++--- .../reference/apis/js-apis-inputdevice.md | 8 ++--- .../reference/apis/js-apis-inputmonitor.md | 34 +++++++++++-------- .../reference/apis/js-apis-pointer.md | 12 +++++-- 4 files changed, 44 insertions(+), 25 deletions(-) mode change 100644 => 100755 zh-cn/application-dev/reference/apis/js-apis-pointer.md diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md b/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md index 96022038df..7f9be5cf41 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md @@ -36,9 +36,10 @@ on(type: "key", keyOptions: KeyOptions, callback: Callback<KeyOptions>): v **示例:** ```js -let powerKeyCode = 18; +let leftAltKey = 2045; +let tabKey = 2049; try { - inputConsumer.on("key", {preKeys: [], finalKey: powerKeyCode, isFinalKeyDown: true, finalKeyDownDuration: 0}, keyOptions => { + inputConsumer.on("key", {preKeys: [leftAltKey], finalKey: tabKey, isFinalKeyDown: true, finalKeyDownDuration: 0}, keyOptions => { console.log(`keyOptions: ${JSON.stringify(keyOptions)}`); }); } catch (error) { @@ -66,27 +67,33 @@ off(type: "key", keyOptions: KeyOptions, callback?: Callback<KeyOptions>): **示例:** ```js +let leftAltKey = 2045; +let tabKey = 2049; // 取消订阅单个回调函数 let callback = function (keyOptions) { console.log(`keyOptions: ${JSON.stringify(keyOptions)}`); } -let keyOption = {preKeys: [], finalKey: powerKeyCode, isFinalKeyDown: true, finalKeyDownDuration: 0}; +let keyOption = {preKeys: [leftAltKey], finalKey: tabKey, isFinalKeyDown: true, finalKeyDownDuration: 0}; try { inputConsumer.on("key", keyOption, callback); inputConsumer.off("key", keyOption, callback); + console.log(`Unsubscribe success`); } catch (error) { console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` ```js +let leftAltKey = 2045; +let tabKey = 2049; // 取消订阅所有回调函数 let callback = function (keyOptions) { console.log(`keyOptions: ${JSON.stringify(keyOptions)}`); } -let keyOption = {preKeys: [], finalKey: powerKeyCode, isFinalKeyDown: true, finalKeyDownDuration: 0}; +let keyOption = {preKeys: [leftAltKey], finalKey: tabKey, isFinalKeyDown: true, finalKeyDownDuration: 0}; try { inputConsumer.on("key", keyOption, callback); inputConsumer.off("key", keyOption); + console.log(`Unsubscribe success`); } 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 5ddc299f65..ecd2d4b196 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @@ -194,19 +194,19 @@ off(type: "change", listener?: Callback<DeviceListener>): void **示例**: ```js -callback: function(data) { +function callback(data) { console.log(`Report device event info: ${JSON.stringify(data, [`type`, `deviceId`])}`); -} +}; try { - inputDevice.on("change", this.callback); + inputDevice.on("change", callback); } catch (error) { console.log(`Listen device event failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } // 取消指定的监听。 try { - inputDevice.off("change", this.callback); + inputDevice.off("change", callback); } catch (error) { console.log(`Cancel listening device event failed, 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 06de18434c..242b63a32a 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md @@ -96,13 +96,14 @@ off(type: "touch", receiver?: TouchEventReceiver): void ```js // 取消监听单个回调函数 -callback: function(touchEvent) { +function callback(touchEvent) { console.log(`Monitor on success ${JSON.stringify(touchEvent)}`); return false; -}, +}; try { - inputMonitor.on("touch", this.callback); - inputMonitor.off("touch", this.callback); + inputMonitor.on("touch", callback); + inputMonitor.off("touch", callback); + console.log(`Monitor off success`); } catch (error) { console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } @@ -110,13 +111,14 @@ try { ```js // 取消监听所有回调函数 -callback: function(touchEvent) { +function callback(touchEvent) { console.log(`Monitor on success ${JSON.stringify(touchEvent)}`); return false; -}, +}; try { - inputMonitor.on("touch", this.callback); + inputMonitor.on("touch", callback); inputMonitor.off("touch"); + console.log(`Monitor off success`); } catch (error) { console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } @@ -141,12 +143,14 @@ off(type: "mouse", receiver?: Callback<MouseEvent>): void ```js // 取消监听单个回调函数 -callback: function(mouseEvent) { +function callback(mouseEvent) { console.log(`Monitor on success ${JSON.stringify(mouseEvent)}`); -}, + return false; +}; try { - inputMonitor.on("mouse", this.callback); - inputMonitor.off("mouse", this.callback); + inputMonitor.on("mouse", callback); + inputMonitor.off("mouse", callback); + console.log(`Monitor off success`); } catch (error) { console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } @@ -154,12 +158,14 @@ try { ```js // 取消监听所有回调函数 -callback: function(mouseEvent) { +function callback(mouseEvent) { console.log(`Monitor on success ${JSON.stringify(mouseEvent)}`); -}, + return false; +}; try { - inputMonitor.on("mouse", this.callback); + inputMonitor.on("mouse", callback); inputMonitor.off("mouse"); + console.log(`Monitor off success`); } catch (error) { console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } diff --git a/zh-cn/application-dev/reference/apis/js-apis-pointer.md b/zh-cn/application-dev/reference/apis/js-apis-pointer.md old mode 100644 new mode 100755 index 44cfe78aee..ca40808f64 --- a/zh-cn/application-dev/reference/apis/js-apis-pointer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-pointer.md @@ -153,7 +153,7 @@ try { } console.log(`Set pointer speed success`); }); -} catch (err) { +} catch (error) { console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -208,14 +208,14 @@ getPointerSpeed(callback: AsyncCallback<number>): void ```js try { - pointer.getPointerSpeed(speed, (error, speed) => { + pointer.getPointerSpeed((error, speed) => { if (error) { console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); return; } console.log(`Get pointer speed success, speed: ${JSON.stringify(speed)}`); }); -} catch (err) { +} catch (error) { console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -294,6 +294,12 @@ getPointerStyle(windowId: number): Promise<PointerStyle> **参数**: +| 参数 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | -------- | +| windowId | number | 是 | 窗口id。 | + +**返回值**: + | 参数 | 说明 | | ---------------------------------------- | ------------------- | | Promise<[PointerStyle](#pointerstyle9)> | Promise实例,异步返回鼠标样式类型。 | -- GitLab