Events
Input events: mouse, keyboard, and window lifecycle.
Syncromesh routes SDL3 input through the Helix/Event system. Register listeners with Event.on(name, callback) in your bootstrap script. Mouse events include both screen-space and world-space coordinates (projected through the camera). You can also dispatch your own in-script events with Event.emit(name, payload) for local UI/action buses.
Import #
import * as Event from 'Helix/Event';Custom events #
import * as Event from 'Helix/Event';
Event.on('ui:action', (payload) => {
if (payload.type === 'burst') {
// route to board-specific behavior
}
});
Event.emit('ui:action', { type: 'burst', source: 'button' });Mouse events #
These are global input events. UI elements can handle pointer input first via Helix/UserInterface callbacks such as onMouseDown, onMouseUp, and onMouseScroll; when an element-level handler consumes a button or scroll event, the corresponding global mouse event is not emitted.
mouseMove #
eventPoint — Screen-space position{ x, y }.worldPoint optional — World-space position (if a window is active).
mouseDown #
eventPoint — Screen-space position{ x, y }.buttonnumber — Mouse button index.worldPoint optional — World-space position.
mouseUp #
eventPoint — Screen-space position{ x, y }.buttonnumber — Mouse button index.worldPoint optional — World-space position.
mouseScroll #
eventPoint — Screen-space position{ x, y }.deltanumber — Scroll delta (positive = up/forward).worldPoint optional — World-space position.
Window events #
closed #
Fired when a window close is requested. No event payload.
ready #
Fired after the engine has initialised and the bootstrap script has completed. Also fired after a RELOAD.
preRender #
Fired from the render pipeline when render_begin is reached. This event is coalesced behind a fence: it is only dispatched when the previous preRender callback is idle, and intermediate frames may be skipped.
windowIdnumber — Window id currently rendering.timenumber — Engine time in seconds for this render pass.integrationnumber — Render interpolation alpha supplied by the engine.
Examples #
import * as Event from 'Helix/Event';
Event.on('ready', () => {
console.log('Engine ready');
});
Event.on('mouseDown', (e) => {
console.log(`Click at screen ${e.event.x},${e.event.y}`);
if (e.world) console.log(`World ${e.world.x},${e.world.y}`);
});
Event.on('keyDown', (e) => {
if (e.code === 41) { // Escape
// handle escape
}
});
Event.on('closed', () => {
Simulation.quit();
});