MCPcopy Create free account
hub / github.com/melonjs/melonJS / onPointerEvent

Function onPointerEvent

packages/melonjs/src/input/pointerevent.ts:527–548  ·  view source on GitHub ↗

* mouse/touch/pointer event management (start/down, end/up) * @ignore

(e: Event)

Source from the content-addressed store, hash-verified

525 * @ignore
526 */
527function onPointerEvent(e: Event): void {
528 // normalize eventTypes
529 normalizeEvent(e);
530
531 // remember/use the first "primary" normalized event for pointer.bind
532 const button = normalizedEvents[0].button;
533
534 // dispatch event to registered objects
535 if (dispatchEvent(normalizedEvents) || e.type === "wheel") {
536 // always preventDefault for wheel event (?legacy code/behavior?)
537 if (preventDefault) {
538 e.preventDefault();
539 }
540 }
541
542 const keycode = pointer.bind[button];
543
544 // check if mapped to a key
545 if (keycode) {
546 triggerKeyEvent(keycode, POINTER_DOWN.includes(e.type), button + 1);
547 }
548}
549
550/*
551 * PUBLIC STUFF

Callers

nothing calls this directly

Calls 4

triggerKeyEventFunction · 0.90
normalizeEventFunction · 0.85
dispatchEventFunction · 0.85
preventDefaultMethod · 0.80

Tested by

no test coverage detected