Skip to content Skip to sidebar Skip to footer

App Lab Mouse Coordinates

I recently started using App Lab on Code.org (found here), which uses a strange JS library. What is the function to find mouse coordinates? I've looked all over and no one has ment

Solution 1:

Source of the information below

Here's an example that uses a click event and logs the mouse coordinates to the console:

// button1 is the id of a button I added in Design mode.
onEvent("button1", "click", function(event) {
  console.log(event.x + " " + event.y);
});

To see the onEvent documentation for App Lab, make sure you're in Code mode (not Design mode) and make sure to blocks showing (not text), then hover over the block in the toolbox (not the blocks in the workspace).

Solution 2:

You can know the mouse position any time with this code:

onEvent("screen1", "mousemove", function(event) {
  console.log(event.x + " " + event.y);
});

Post a Comment for "App Lab Mouse Coordinates"