我最近开始使用Code.org上的App Lab (found here),它使用了一个奇怪的JS库。查找鼠标坐标的功能是什么?我已经找遍了,但没有人提到它。
(如果你不知道什么是app lab,它是一个code.org编译器,它可以让你编写JS程序,然后把它发送到你的手机上,制作小应用程序)
发布于 2018-03-16 04:19:10
Source of the information below
下面是一个使用click事件并将鼠标坐标记录到控制台的示例:
// button1 is the id of a button I added in Design mode.
onEvent("button1", "click", function(event) {
console.log(event.x + " " + event.y);
});要查看App Lab的onEvent文档,请确保您处于代码模式(而不是设计模式),并确保显示块(而不是文本),然后将鼠标悬停在工具箱中的块(而不是工作区中的块)上。
发布于 2019-02-14 08:16:34
你可以使用下面的代码随时知道鼠标的位置:
onEvent("screen1", "mousemove", function(event) {
console.log(event.x + " " + event.y);
});https://stackoverflow.com/questions/44012529
复制相似问题