Open
Description
Per html5.h, event handlers can return TRUE to consume the event, i.e., event.preventDefault()
is called. This does not work in Asyncify.
Here's a simple test case for mouse events:
The expected result is that the default handler is never invoked on the canvas, e.g., mouse clicks do not cause the canvas to gain focus.
I saw that the event handlers check the result of dynCall_iiii()
to determine whether to call e.preventDefault()
. This result is never passed in Asyncify.
Therefore, I get the desired result if I modify the compiled Module as below:
function registerMouseEventCallback(target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString, targetThread) {
/* ... */
var mouseEventHandlerFunc = function(ev) {
var e = ev || event;
// TODO: Make this access thread safe, or this could update live while app is reading it.
fillMouseEventData(JSEvents.mouseEvent, e, target);
- if ((function(a1, a2, a3) { dynCall_iiii.apply(null, [callbackfunc, a1, a2, a3]); })(eventTypeId, JSEvents.mouseEvent, userData)) e.preventDefault();
+ if ((function(a1, a2, a3) { return dynCall_iiii.apply(null, [callbackfunc, a1, a2, a3]); })(eventTypeId, JSEvents.mouseEvent, userData)) e.preventDefault();
};
/* ... */
}
See Asyncify build with the fix applied, which passes the test.
Is this fix appropriate? If so, I can use guidance on patching the codebase as I'm unfamiliar with Asyncify modifications.