0
How do I get the coordinates of the mouse?
How do I get the coordinates of the mouse in JS ( or other languages that are used to make webpages ) on a canvas / SVG (whichever)? As example, if I want to make a button on a canvas that should be clicked and its in the middle of the canvas and ten times smaller than the canvas, is it possible to make something like the "onclick" event handler without making a HTML button, by making a button image on the canvas?
2 odpowiedzi
+ 4
You just have to check if the mouse click is within the area of the canvas button.
Here's a reference for the mouse event
https://www.w3schools.com/jsref/event_clientx.asp
0
Thanks, that was really helpful.