Skip to content
bg2 engine

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.

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

Indicates whether event propagation has been stopped.

  • Returns true if stopPropagation() has been called
  • Returns false otherwise

Stops further propagation of the event.

Once this method is called, the event will not be forwarded to additional handlers within the event system.


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.

mouseWheel(evt: Bg2MouseEvent) {
console.log("Mouse wheel event received");
// Prevent further processing of this event
evt.stopPropagation();
}