Hi I'm trying to display or capture the mouse coordinates in my program. In this program, you can click on any button and corresponding image will appear. I want to display the mouse coordinates on this too.
I tried the following code but it doesn't work. Please let me know where I am going wrong.
canvas.on('mouse:down', function(options){
getMouse(options);// its not an event its options of your canvas object
});
function getMouse(options) {
console.log(options);// you can check all options here
console.log(options.e.clientX);
}
The fiddle is: http://jsfiddle.net/wv9MU/9/
This could be your getMouse function:
function getMouse(options) {
p = canvas.getPointer(options.e);
document.getElementById('mouse').value = '' + p.x.toFixed() + ', ' + p.y.toFixed(0);
}
This is a unpdated working fiddle. http://jsfiddle.net/wv9MU/22/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.