[simulator/web] Fix keyHandler not defined (backported from Upsilon Workshop)

This commit is contained in:
Yaya-Cout
2025-12-14 12:02:58 +01:00
parent 2233ca341b
commit 26ee665d50

View File

@@ -54,6 +54,9 @@ function Calculator(emModule) {
function eventHandler(keyHandler) { function eventHandler(keyHandler) {
return function(ev) { return function(ev) {
var key = this.getAttribute('data-key'); var key = this.getAttribute('data-key');
/* We use eval as "emModule._IonSimulatorKeyboardKeyDown" is still missing
* even after loading Epsilon, probably due to some async init */
keyHandler = eval(keyHandler);
keyHandler(key); keyHandler(key);
/* Always prevent default action of event. /* Always prevent default action of event.
* First, this will prevent the browser from delaying that event. Indeed * First, this will prevent the browser from delaying that event. Indeed
@@ -69,8 +72,8 @@ function Calculator(emModule) {
ev.preventDefault(); ev.preventDefault();
}; };
} }
var downHandler = eventHandler(emModule._IonSimulatorKeyboardKeyDown); var downHandler = eventHandler("emModule._IonSimulatorKeyboardKeyDown");
var upHandler = eventHandler(emModule._IonSimulatorKeyboardKeyUp); var upHandler = eventHandler("emModule._IonSimulatorKeyboardKeyUp");
calculatorElement.querySelectorAll('span').forEach(function(span){ calculatorElement.querySelectorAll('span').forEach(function(span){
/* We decide to hook both to touch and mouse events /* We decide to hook both to touch and mouse events