I am new to KineticJS and am not being able to get the mouse coordinates of the Stage on mousedown
. I managed to display the coordinates with mouseout
and mouseover
but mousedown
seems only to work on the image/shape that has been added to the Stage, but not the Stage itself.
Can anyone explain to me why is it so? and help me with a solution please.
this is the example I tried with:
Code:
stage.on('mouseout', function() {
var mousePos = stage.getMousePosition();
writeMessage(messageLayer, 'Mouseout triangle:' + mousePos.x);
});
stage.on('mouseout','mousemove', function() {
});
stage.on('mousedown', function() {
alert('OK!');
});
jQuery event listener functions have event params passed in that contain all the information you'll ever need. In this case, you'll maybe want offsetX and offsetY.
$('body').click(function (e) {
console.log(e.offsetX, e.offsetY);
});
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.