setUpFileEvents

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

Bridges browser file drag-and-drop input into the engine’s typed window event resources. The DOMWindowPlugin integration uses this helper after registering a canvas.

The dragover listener constructs and writes a FileDrag event, then calls event.preventDefault(). The drop listener constructs and writes a FileDrop event, then also calls event.preventDefault(). No event propagation is stopped. Each event is written through the matching typed Events resource, resolved with typeidGeneric(Events, [FileDrag]) or typeidGeneric(Events, [FileDrop]).

The target must provide addEventListener and accept browser drag events; the DOM integration passes an HTMLCanvasElement. The world must already contain the Events<FileDrag> and Events<FileDrop> resources, normally supplied by the WindowPlugin required by the DOMWindowPlugin.

Examples

// DOMWindowPlugin calls this for the canvas registered for a Window.
setUpFileEvents(world, canvas)

Parameters

NameDescriptionDefault
world

World containing the typed Events resources.

—
target

DOM element that receives drag-and-drop events.

—