未验证 提交 39cd00d0 编写于 作者: N ningning 提交者: Gitee

update zh-cn/application-dev/device/pointerstyle-guidelines.md.

Signed-off-by: Nningning <3248127340@qq.com>
上级 e4fba9e4
...@@ -77,13 +77,17 @@ try { ...@@ -77,13 +77,17 @@ try {
5. 设置鼠标光标样式为默认样式。 5. 设置鼠标光标样式为默认样式。
```js ```js
import pointer from '@ohos.multimodalInput.pointer';
import window from '@ohos.window'; import window from '@ohos.window';
// 1.开发者使能取色功能 // 1.开发者使能取色功能
// 2.调用窗口实例获取对应的窗口id // 2.调用窗口实例获取对应的窗口id
window.getTopWindow((error, windowClass) => { window.getLastWindow(this.context, (error, windowClass) => {
windowClass.getProperties((error, data) => { if (error.code) {
var windowId = data.id; console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
return;
}
var windowId = windowClass.getWindowProperties().id;
if (windowId < 0) { if (windowId < 0) {
console.log(`Invalid windowId`); console.log(`Invalid windowId`);
return; return;
...@@ -94,14 +98,16 @@ window.getTopWindow((error, windowClass) => { ...@@ -94,14 +98,16 @@ window.getTopWindow((error, windowClass) => {
console.log(`Successfully set mouse pointer style`); console.log(`Successfully set mouse pointer style`);
}); });
} catch (error) { } catch (error) {
console.log(`Failed to set the pointer style, error=${JSON.stringify(error)}, msg=${JSON.stringify(message)}`); console.log(`Failed to set the pointer style, error=${JSON.stringify(error)}, msg=${JSON.stringify(`message`)}`);
} }
});
}); });
// 4.取色结束 // 4.取色结束
window.getTopWindow((error, windowClass) => { window.getLastWindow(this.context, (error, windowClass) => {
windowClass.getProperties((error, data) => { if (error.code) {
var windowId = data.id; console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
return;
}
var windowId = windowClass.getWindowProperties().id;
if (windowId < 0) { if (windowId < 0) {
console.log(`Invalid windowId`); console.log(`Invalid windowId`);
return; return;
...@@ -112,8 +118,7 @@ window.getTopWindow((error, windowClass) => { ...@@ -112,8 +118,7 @@ window.getTopWindow((error, windowClass) => {
console.log(`Successfully set mouse pointer style`); console.log(`Successfully set mouse pointer style`);
}); });
} catch (error) { } catch (error) {
console.log(`Failed to set the pointer style, error=${JSON.stringify(error)}, msg=${JSON.stringify(message)}`); console.log(`Failed to set the pointer style, error=${JSON.stringify(error)}, msg=${JSON.stringify(`message`)}`);
} }
});
}); });
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册