From 5d85eae4c55990e8b1d5543deb6111f1b82bde0e Mon Sep 17 00:00:00 2001 From: mayunteng_1 Date: Thu, 29 Dec 2022 10:42:29 +0800 Subject: [PATCH] multimodalinput docs modify Signed-off-by: mayunteng_1 Change-Id: I6f8f0dad486e7a8476d72ea113430d9ea0dfeeb4 --- zh-cn/application-dev/device/inputdevice-guidelines.md | 6 +++--- .../application-dev/reference/apis/js-apis-pointer.md | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/zh-cn/application-dev/device/inputdevice-guidelines.md b/zh-cn/application-dev/device/inputdevice-guidelines.md index d08fbacfef..81a808458a 100644 --- a/zh-cn/application-dev/device/inputdevice-guidelines.md +++ b/zh-cn/application-dev/device/inputdevice-guidelines.md @@ -16,8 +16,8 @@ import inputDevice from '@ohos.multimodalInput.inputDevice'; | 实例名 | 接口名 | 说明 | | ----------- | ------------------------------------------------------------ | -------------------------- | -| inputDevice | function getDeviceList(callback: AsyncCallback\>): void; | 获取输入设备列表。 | -| inputDevice | function getKeyboardType(deviceId: number, callback: AsyncCallback\): void; | 获取输入设备的键盘类型。 | +| inputDevice | function getDeviceList(): Promise\>; | 获取输入设备列表。 | +| inputDevice | function getKeyboardType(deviceId: number): Promise\; | 获取输入设备的键盘类型。 | | inputDevice | function on(type: "change", listener: Callback\): void; | 监听输入设备的热插拔事件。 | | inputDevice | function off(type: "change", listener?: Callback\): void; | 取消监听输入设备的热插拔事件。 | @@ -51,7 +51,7 @@ try { // 2.监听设备热插拔 inputDevice.on("change", (data) => { console.log(`Device event info: ${JSON.stringify(data)}`); - inputDevice.getKeyboardType(data.deviceId, (error, type) => { + inputDevice.getKeyboardType(data.deviceId).then((type) => { console.log("The keyboard type is: " + type); if (type === inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') { // 物理键盘已插入 diff --git a/zh-cn/application-dev/reference/apis/js-apis-pointer.md b/zh-cn/application-dev/reference/apis/js-apis-pointer.md index cb8bab502a..014b704990 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-pointer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-pointer.md @@ -122,9 +122,13 @@ isPointerVisible(): Promise<boolean> **示例**: ```js -pointer.isPointerVisible().then((visible) => { - console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`); -}); +try { + pointer.isPointerVisible().then((visible) => { + console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`); + }); +} catch (error) { + console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} ``` ## pointer.setPointerSpeed9+ -- GitLab