EventBase
The EventBase class is the foundational type for all input and interaction events in the bg2 engine TypeScript API. It provides a minimal interface to control event propagation within the engine’s event dispatch system.
All specific event types (keyboard, mouse, touch, etc.) extend this class and inherit its propagation control mechanism.
Purpose
Section titled “Purpose”EventBase allows event handlers to signal whether an event should continue propagating through the system or be stopped after being handled.
This is useful when:
- An event has been fully handled and should not trigger additional handlers
- Multiple layers of the application listen to the same event
- Preventing default or secondary behaviors
Properties
Section titled “Properties”isEventPropagationStopped: boolean
Section titled “isEventPropagationStopped: boolean”Indicates whether event propagation has been stopped.
- Returns
trueifstopPropagation()has been called - Returns
falseotherwise
Methods
Section titled “Methods”stopPropagation(): void
Section titled “stopPropagation(): void”Stops further propagation of the event.
Once this method is called, the event will not be forwarded to additional handlers within the event system.
Usage Notes
Section titled “Usage Notes”Event propagation control is typically used inside input handlers such as mouseWheel, mouseDown, or keyDown.
The engine checks the propagation state after each handler invocation and stops dispatching the event if propagation has been cancelled.
Example
Section titled “Example”mouseWheel(evt: Bg2MouseEvent) { console.log("Mouse wheel event received");
// Prevent further processing of this event evt.stopPropagation();}