Class DOMRoot

Like Root, but for easy use in an HTML page.

Instead of calling each individual update method, simply call update on every animation frame. Drivers still need to be manually registered.

Hierarchy

Constructors

Properties

_currentPointerStyle: string = 'default'

The actual current pointer style.

For internal use only.

See pointerStyle

_enabled: boolean = true

Is the Root enabled? For internal use only.

See enabled

_foci: Map<FocusType, null | Widget> = ...

Current component foci (event targets for each focus type).

For internal use only.

See requestFocus, dropFocus, clearFocus and getFocus

_fociCapturers: Map<FocusType, null | Widget> = ...

Last capturer of each component focus (event targets for each focus type).

For internal use only.

See getFocusCapturer

_mobileTextInUse: boolean = false

Is the mobile-friendly text input in use?

For internal use only.

See hasMobileTextInput, usingMobileTextInput and getTextInput

domCanvasContext: CanvasRenderingContext2D

This root's canvas element's context. Used for painting

domElem: HTMLCanvasElement

This root's canvas element. Add this to the HTML body

drivers: Set<Driver> = ...

The list of drivers registered to this root

pointerStyle: string = 'default'

The pointer style this root wants. Will be set on postLayoutUpdate by pointerStyleHandler

pointerStyleHandler: null | PointerStyleHandler

Pointer style handler, decides how to show the given pointer style. Normally a function which sets the CSS cursor style of the Root's canvas

textInputHandler: null | TextInputHandler = null

Handler for mobile-friendly text input. If not null, widgets that need text may call this to get a string.

See hasMobileTextInput, usingMobileTextInput and getTextInput

viewport: CanvasViewport

The internal viewport. Manages drawing

Accessors

  • get enabled(): boolean
  • Is this root enabled? If not enabled, painting, updating or resolving layout will do nothing. Drivers will also be notified by calling onEnable or onDisable, pointer style will be reset (updatePointerStyle called with 'default') and all foci will be cleared (clearFocus).

    See _enabled

    Returns boolean

  • set enabled(newEnabled: boolean): void
  • Parameters

    • newEnabled: boolean

    Returns void

  • get maxCanvasHeight(): number
  • Shortcut for viewport's maxCanvasHeight property

    Returns number

  • set maxCanvasHeight(maxCanvasHeight: number): void
  • Parameters

    • maxCanvasHeight: number

    Returns void

  • get maxCanvasWidth(): number
  • Shortcut for viewport's maxCanvasWidth property

    Returns number

  • set maxCanvasWidth(maxCanvasWidth: number): void
  • Parameters

    • maxCanvasWidth: number

    Returns void

  • get preventBleeding(): boolean
  • Shortcut for viewport's preventBleeding property.

    Returns boolean

  • set preventBleeding(preventBleeding: boolean): void
  • Parameters

    • preventBleeding: boolean

    Returns void

  • get resolution(): number
  • Shortcut for viewport's resolution property.

    Note that, although the resolution is part of the CanvasViewport API, widgets will treat the resolution property as being per-Root, not per-Viewport (hence the lack of a Viewport.resolution property). The resolution property is part of the CanvasViewport class so that CanvasViewport is not circularly dependent on the Root class.

    Returns number

  • set resolution(resolution: number): void
  • Parameters

    • resolution: number

    Returns void

Methods

  • Counter Root viewport scaling with an opposite CSS scale (via width and height, not CSS transforms).

    Returns void

  • Destroy this Root. Disables the Root, clears all drivers, detaches the child Widget and resets textInputHandler.

    Root must not be used after calling this method. Doing so will cause exceptions to be thrown. There is no way to un-destroy a destroyed Root.

    Call this if you are no longer going to use this Root.

    Returns void

  • Get text input from the user. Used for mobile where keyboard events are hard to get.

    Returns

    If this is already in use (usingMobileTextInput), returns null, else, returns a string typed by the user.

    Parameters

    • initialInput: string = ''

    Returns Promise<null | string>

  • Paint this root's next frame if needed. Does nothing if root is disabled.

    Calls viewport's paint with child.

    Call this after calling postLayoutUpdate.

    Returns

    Returns whether the child was dirty or not. Use this to tell an external 3D library whether to update a mesh's texture or not.

    Returns boolean

Generated using TypeDoc