setupPointerEvents

View sourcesetupPointerEvents(world: World, target: HTMLElement): void

Attaches browser pointer and wheel listeners to a DOM target. Each listener resolves the matching typed Events resource with typeidGeneric, constructs the corresponding window event from the browser event, and writes it to that resource.

The listeners map browser event names to window event values:

Wheel defaults are suppressed and the target’s browser context menu is suppressed so a window-backed canvas owns its pointer surface.

The target must provide addEventListener; a HTMLElement such as a canvas can be used. The World must already contain an Events resource for each listed event type. Calling this helper again adds another set of listeners; it does not return a cleanup function.

Examples

// Forward input from a canvas into the world's typed event resources.
setupPointerEvents(world, canvas)

Parameters

NameDescriptionDefault
world

World containing the typed event resources.

—
target

HTMLElement receiving pointer and wheel events.

—