Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EventHandler

... Provider and event handler are explicitly separated in order to reduce the number of observables (reuse of event provider for multiple handler).

Hierarchy

  • EventHandler

Index

Constructors

constructor

Properties

Protected _invalidate

_invalidate: Invalidate | undefined

The event handler's invalidation callback. This should usually be setup by the owning renderer and invoke the same callback the renderer has been given by the canvas. This invalidation is required, when continuous rendering is not present, events might cause need for new rendering requests.

Protected _latestMouseEventsByType

_latestMouseEventsByType: Map<Type, MouseEvent[]> = new Map<MouseEventProvider.Type, Array<MouseEvent>>()

Protected _latestTouchEventsByType

_latestTouchEventsByType: Map<Type, TouchEvent[]> = new Map<TouchEventProvider.Type, Array<TouchEvent>>()

Protected _mouseEventHandlerByType

_mouseEventHandlerByType: Map<Type, MouseEventHandler[]> = new Map<MouseEventProvider.Type, Array<MouseEventHandler>>()

Protected _mouseEventProvider

_mouseEventProvider: MouseEventProvider | undefined

Assigned mouse event provider. This is usually created and owned by the canvas.

Protected _previousMouseEventsByType

_previousMouseEventsByType: Map<Type, MouseEvent[]> = new Map<MouseEventProvider.Type, Array<MouseEvent>>()

Protected _previousTouchEventsByType

_previousTouchEventsByType: Map<Type, TouchEvent[]> = new Map<TouchEventProvider.Type, Array<TouchEvent>>()

Protected _subscriptions

_subscriptions: Subscription[] = new Array<Subscription>()

Protected _touchEventHandlerByType

_touchEventHandlerByType: Map<Type, TouchEventHandler[]> = new Map<TouchEventProvider.Type, Array<TouchEventHandler>>()

Protected _touchEventProvider

_touchEventProvider: TouchEventProvider | undefined

Assigned touch event provider. This is usually created and owned by the canvas.

Methods

dispose

  • dispose(): void
  • Disposes all registered handlers of all event types.

    Returns void

exitPointerLock

  • exitPointerLock(): void
  • Forward pointer lock release request to the mouse event provider (if one exists).

    Returns void

Protected invalidate

  • invalidate(force?: boolean): void
  • callback

    Invalidate A callback intended to be invoked whenever the specialized event handler itself is invalid. By default only optional updates (renderer decides whether or not to continue redraw) are triggered.

    Parameters

    • Default value force: boolean = false

    Returns void

Protected invokeMouseEventHandler

  • invokeMouseEventHandler(type: Type): void

Protected invokeTouchEventHandler

  • invokeTouchEventHandler(type: Type): void

offsets

  • offsets(event: MouseEvent | WheelEvent | TouchEvent, normalize?: boolean): Array<vec2>
  • Normalize mouse and touch event coordinates for various browsers.

    Parameters

    • event: MouseEvent | WheelEvent | TouchEvent

      Mouse, wheel, or touch event.

    • Default value normalize: boolean = true

      Whether or not to compute normalized coordinates (offsets).

    Returns Array<vec2>

    • Array of normalized x and y offsets (in case of multiple touches).

pushClickHandler

  • Register a click event handler that is to be called on update iff at least a single click event has occurred since last update.

    Parameters

    Returns void

pushMouseDownHandler

  • Register an mouse down event handler that is to be called on update iff at least a single mouse down event has occurred since last update.

    Parameters

    Returns void

pushMouseEnterHandler

  • Register an mouse enter event handler that is to be called on update iff at least a single mouse enter event has occurred since last update.

    Parameters

    Returns void

Protected pushMouseEventHandler

  • Utility for registering an additional mouse event handler for updates on mouse events of the given type. The handler is to be called on update iff at least a single mouse event of the given type has occurred since last update.

    Parameters

    • type: Type

      Mouse event type the handler is to be associated with.

    • handler: MouseEventHandler

      Handler to be called on update.

    Returns void

pushMouseLeaveHandler

  • Register an mouse leave event handler that is to be called on update iff at least a single mouse leave event has occurred since last update.

    Parameters

    Returns void

pushMouseMoveHandler

  • Register an mouse move event handler that is to be called on update iff at least a single mouse move event has occurred since last update.

    Parameters

    Returns void

pushMouseUpHandler

  • Register an mouse up event handler that is to be called on update iff at least a single mouse up event has occurred since last update.

    Parameters

    Returns void

pushMouseWheelHandler

  • Register an mouse wheel event handler that is to be called on update iff at least a single mouse wheel event has occurred since last update.

    Parameters

    Returns void

pushTouchCancelHandler

  • Register a touch cancel event handler that is to be called on update iff at least a single touch cancel event has occurred since last update.

    Parameters

    Returns void

pushTouchEndHandler

  • Register a touch end event handler that is to be called on update iff at least a single touch end event has occurred since last update.

    Parameters

    Returns void

Protected pushTouchEventHandler

  • Utility for registering an additional touch event handler for updates on touch events of the given type. The handler is to be called on update iff at least a single touch event of the given type has occurred since last update.

    Parameters

    • type: Type

      Touch event type the handler is to be associated with.

    • handler: TouchEventHandler

      Handler to be called on update.

    Returns void

pushTouchMoveHandler

  • Register a touch move event handler that is to be called on update iff at least a single touch move event has occurred since last update.

    Parameters

    Returns void

pushTouchStartHandler

  • Register a touch start event handler that is to be called on update iff at least a single touch start event has occurred since last update.

    Parameters

    Returns void

requestPointerLock

  • requestPointerLock(): void
  • Forward pointer lock request to the mouse event provider (if one exists).

    Returns void

update

  • update(): void
  • Triggers (by means of a helper function) invocation of all registered handler of all event types.

    Returns void