A Root is the parent of all widgets, but not a widget itself. It contains a single child and manages dimensions and input handling

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

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

badTabCaptureWarned: boolean = false

Has the warning for poorly captured TabSelect events been issued?

Accessors

  • 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

  • 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

  • Dispatches an Event to this root's child by calling dispatchEvent. Updates foci capturers and notifies drivers by calling onFocusCapturerChanged if the capturer changes. Does nothing if root is disabled.

    Note that if an event with a focus is dispatched and no widget captures the event due to the widget not existing anymore or being disabled, the focus type of the event will be cleared in the root with clearFocus.

    Returns

    Returns true if the event was captured

    Parameters

    Returns boolean

  • 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