[英]How do i get the mouse position of the location i clicked, on a kinetic.js Stage?
我是KineticJS的新手,無法在mousedown
上獲取舞台的鼠標坐標。 我設法通過mouseout
和mouseover
顯示坐標,但是mousedown
似乎只對已添加到舞台上的圖像/形狀起作用,而對舞台本身不起作用。
誰能向我解釋為什么? 並請我提供解決方案。
碼:
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事件偵聽器函數傳遞了事件參數,其中包含您將需要的所有信息。 在這種情況下,您可能需要offsetX和offsetY。
$('body').click(function (e) {
console.log(e.offsetX, e.offsetY);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.