Class ThreeVirtualKeyboardRoot

A VirtualKeyboardRoot but it extends ThreeRoot instead of Root, so it can be used for three.js.

Hierarchy

Constructors

Properties

_currentPointerStyle: string

The actual current pointer style.

For internal use only.

See Root#pointerStyle

_enabled: boolean

Is the Root enabled? For internal use only.

See Root#enabled

_foci: Map<FocusType, null | Widget>

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

For internal use only.

See Root#requestFocus, Root#dropFocus, Root#clearFocus and Root#getFocus

_fociCapturers: Map<FocusType, null | Widget>

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

For internal use only.

See Root#getFocusCapturer

_mobileTextInUse: boolean

Is the mobile-friendly text input in use?

For internal use only.

See Root#hasMobileTextInput, Root#usingMobileTextInput and Root#getTextInput

drivers: Set<Driver>

The list of drivers registered to this root

keyboardDriver: KeyboardDriver

The KeyboardDriver used by this root's virtual keyboard.

mesh: Mesh<BufferGeometry, Material | Material[]>

The mesh used for rendering the canvas. Saved so that its scale can be changed later.

object: Object3D<Event>

An object that contains the canvas' mesh which can be added to a scene. Not actually a Mesh, but an Object3D which contains a mesh, so that the mesh can be resized without interfering with the transformAlgorithm.

pointerStyle: string

The pointer style this root wants. Will be set on Root#postLayoutUpdate by Root#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

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

See Root#hasMobileTextInput, Root#usingMobileTextInput and Root#getTextInput

transformAlgorithm: null | TransformAlgorithm

Transform algorithm; decides how to position the canvas' mesh in the world. Can be changed later and is called on update.

viewport: CanvasViewport

The internal viewport. Manages drawing

Accessors

  • get canvas(): HTMLCanvasElement
  • The Root#viewport's CanvasViewport#canvas | canvas

    Returns HTMLCanvasElement

  • get canvasDimensions(): [number, number]
  • The Root#viewport's CanvasViewport#canvasDimensions | canvasDimensions

    Returns [number, number]

  • get child(): Widget
  • The root widget of this UI tree. Equivalent to getting Root#viewport.Viewport#child.

    Returns Widget

  • get constraints(): LayoutConstraints
  • The Root#viewport's Viewport#constraints | constraints

    Returns LayoutConstraints

  • set constraints(constraints: LayoutConstraints): void
  • Parameters

    Returns void

  • get dimensions(): [number, number]
  • The Root#child's Widget#dimensions | dimensions

    Returns [number, number]

  • get effectiveScale(): [scaleX: number, scaleY: number]
  • Get the scale used for the Root#viewport. The horizontal and/or vertical scale may not be 1 if Root#maxCanvasWidth or Root#maxCanvasHeight are exceeded.

    Note that this is only valid after resolving Root#child's layout.

    Equivalent to getting Viewport#effectiveScale on Root#viewport.

    Returns [scaleX: number, scaleY: number]

  • get enabled(): boolean
  • Returns boolean

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

    • enabled: boolean

    Returns void

  • get hasMobileTextInput(): boolean
  • Can Root#getTextInput be called? True if Root#textInputHandler is not null and Root#usingMobileTextInput is false.

    Returns boolean

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

    Returns number

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

    • maxCanvasHeight: number

    Returns void

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

    Returns number

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

    • maxCanvasWidth: number

    Returns void

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

    Returns boolean

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

    • preventBleeding: boolean

    Returns void

  • get resolution(): number
  • Shortcut for Root#viewport's CanvasViewport#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

  • get usingMobileTextInput(): boolean
  • Is Root#getTextInput in use?

    See Root#_mobileTextInUse.

    Returns boolean

Methods

  • Unregisters all Root#drivers from the root, by calling Root#unregisterDriver.

    Returns void

  • Clears the current Root#_foci | focus of a given type. If there was a focus set, Root#drivers are notified by calling Driver#onFocusChanged.

    Parameters

    Returns void

  • Cleans up resources used by the Root.

    It's the user's responsibility that the object is removed from all scenes. canvas-ui-three has no knowledge about the available scenes.

    See

    the Root#destroy documentation for more details

    Returns void

  • Dispatches an Event to this root's Root#child by calling Widget#dispatchEvent. Updates Root#_fociCapturers | foci capturers and notifies Root#drivers by calling Driver#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 Root#clearFocus.

    Returns

    Returns true if the event was captured

    Parameters

    Returns boolean

  • Clears all the Root#_foci | foci that are set to a given Widget. Achieved by calling Root#dropFocus

    Parameters

    Returns void

  • Clears the current Root#_foci | focus of a given type if it is currently set to a given widget. Achieved by calling Root#clearFocus.

    Parameters

    Returns void

  • Gets the current Root#_foci | focus of a given type.

    Parameters

    Returns null | Widget

  • Gets the last Root#_fociCapturers | focus capturer of a given type.

    Parameters

    Returns null | Widget

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

    Returns

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

    Parameters

    • Optional initialInput: string

    Returns Promise<null | string>

  • Do a post-layout update; calls Root#child's Widget#postLayoutUpdate and Root#updatePointerStyle. Does nothing if root is disabled.

    Call this before calling Root#paint and after calling Root#resolveLayout

    Returns void

  • Do a pre-layout update; calls Root#drivers' Driver#update and Root#child's Widget#preLayoutUpdate. Does nothing if root is disabled.

    Call this before calling Root#resolveLayout

    Returns void

  • Registers a Driver to the root, adding it to the Root#drivers list and calling Driver#onEnable. If the driver was already registered, nothing happens.

    Parameters

    Returns void

  • Sets the current Root#_foci | focus of a given type to a given widget. If the focus changes, Root#clearFocus is called and Root#drivers are notified by calling Driver#onFocusChanged.

    Parameters

    Returns void

  • Unregisters a Driver from the root, removing it from the Root#drivers list and calling Driver#onDisable. If the driver was not registered, nothing happens.

    Parameters

    Returns void

  • Calls Root#pointerStyleHandler if the Root#pointerStyle has changed (checked by comparing with Root#_currentPointerStyle). Also updates Root#_currentPointerStyle. Can also be optionally supplied a new pointer style.

    Parameters

    • Optional newStyle: null | string

    Returns void

  • Update the visibility of this root; if the keyboard driver has no focused root, then the root is disabled, else, it is enabled. Call this method on every frame to automatically enable/disable the root if needed

    Returns void

Generated using TypeDoc