[英]How does Haxe/OpenFL handle canvas click events?
I am adding a canvas on top of a Haxe HTML5 Game. 我在Haxe HTML5游戏的顶部添加了画布。 But once I do, the buttons in the Haxe game no longer register the click events. 但是一旦完成,Haxe游戏中的按钮将不再注册单击事件。 Does anyone know in the Haxe/openFL compiled code where the click events are being handled? 有人在Haxe / openFL编译代码中知道在哪里处理单击事件吗?
My best guess is that they are looking at the top most canvas, which is now mine and therefore not seeing the hits. 我最好的猜测是他们正在查看最上面的画布,该画布现在属于我的画布,因此看不到点击数。
EDIT: 编辑:
Found this code where the mouse events were being added to the canvas: 找到以下代码,将鼠标事件添加到画布:
while(_g2 < mouseEvents.length) {
var type2 = mouseEvents[_g2];
++_g2;
element1.addEventListener(type2,$bind(this,this.element_onMouse), true);
}
Where element1 = the canvas. 其中element1 =画布。
I can't seem to send $(canvas).click() events to that canvas. 我似乎无法将$(canvas).click()事件发送到该画布。 Anyone have further suggestions? 有人有进一步的建议吗?
My conclusion is, I was using JQuery to send calls to event listeners that were added through plain JavaScript. 我的结论是,我正在使用JQuery将调用发送到通过纯JavaScript添加的事件侦听器。
document.getElemntById("canvas").addEventListener("mousedown", func...);
Apparently the JQuery calls can not call non JQuery events. 显然,JQuery调用不能调用非JQuery事件。
$(canvas).mousedown(); // does not work
Using 运用
document.getElemntById("canvas").dispatchEvent(event) r
and sending MouseEvents to the Haxe canvas worked fine. 并将MouseEvents发送到Haxe画布效果很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.