mach: wasm: Implement mouse press, release, motion and scroll events
This commit is contained in:
parent
efe90fc64f
commit
99dc10e58a
2 changed files with 62 additions and 1 deletions
|
|
@ -191,6 +191,22 @@ const mach = {
|
|||
mach.events.push(...[2, convertKeyCode(ev.code)]);
|
||||
});
|
||||
|
||||
canvas.addEventListener("mousemove", (ev) => {
|
||||
mach.events.push(...[3, ev.clientX, ev.clientY]);
|
||||
});
|
||||
|
||||
canvas.addEventListener("mousedown", (ev) => {
|
||||
mach.events.push(...[4, ev.button]);
|
||||
});
|
||||
|
||||
canvas.addEventListener("mouseup", (ev) => {
|
||||
mach.events.push(...[5, ev.button]);
|
||||
});
|
||||
|
||||
canvas.addEventListener("wheel", (ev) => {
|
||||
mach.events.push(...[6, ev.deltaX, ev.deltaY]);
|
||||
});
|
||||
|
||||
document.body.appendChild(canvas);
|
||||
return mach.canvases.push({ canvas: canvas, title: undefined }) - 1;
|
||||
},
|
||||
|
|
@ -246,6 +262,10 @@ const mach = {
|
|||
return mach.events.shift();
|
||||
},
|
||||
|
||||
machEventShiftFloat() {
|
||||
return mach.machEventShift();
|
||||
},
|
||||
|
||||
machPerfNow() {
|
||||
return performance.now();
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue