Class WLVirtualKeyboardRoot

A WLRoot with a virtual keyboard, similar to VirtualKeyboardRoot from lazy-widgets. Can also be automatically hidden when there is no keyboard focus by callid updateVisibility before calling update. This doesn't need to be directly used, the virtual-keyboard-ui-root component can be used instead.

Hierarchy

Constructors

Properties

_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

_pointerStyleHandler: null | PointerStyleHandler

For internal use only. Current value of Root#pointerStyleHandler.

collision: null | CollisionComponent = null
collisionOverextensionPixels: number
cursorTarget: null | CursorTarget = null
destroyTextureWhenDisabled: boolean
drivers: Set<Driver>

The list of drivers registered to this root

The KeyboardDriver used by this root's virtual keyboard.

materialClone: Material
mesh: null | Mesh = null
meshComponent: null | MeshComponent
meshObject: null | Object3D
oldTexSize: [number, number] = ...
overextendCollisionOnCursorCapture: boolean
paintedOnce: boolean = false
tabFocusable: boolean

Can tab controls be used in this UI root? True by default. Can only be set once when the UI is created.

textInputHandler: null | (new (listener) => TextInputHandler)

Text input handler constructor for environments where getting keyboard input is hard, such as mobile and WebXR. If not null, widgets that need text may call this to get strings and cursor positions as text is typed.

See Root#getTextInput

Type declaration

texture: null | Texture = null
textureUniformName?: string
unitsPerPixel: number
valid: boolean = false
viewport: CanvasViewport

The internal viewport. Manages drawing

defaultCloneMaterial: true = true

Are materials cloned by default?

defaultCollisionGroupsMask: 2 = 2

Default collision groups, as a bitmask

defaultCollisionOverextensionPixels: 16 = 16

How many pixels to over-extend the collision extents by default.

defaultDestroyTextureWhenDisabled: false = false

Should the UI texture be destroyed by default when the root is disabled?

defaultMaxCanvasHeight: 2048 = 2048

Default maximum canvas (texture) height. Smaller than lazy-widget's default value because Wonderland engine has much stricter texture limits due to the texture atlas system.

defaultMaxCanvasWidth: 2048 = 2048

Default maximum canvas (texture) width. Smaller than lazy-widget's default value because Wonderland engine has much stricter texture limits due to the texture atlas system.

defaultOverextendCollisionOnCursorCapture: true = true

Should the collision extents only be over-extended when the cursor is being captured by default?

defaultPreventAtlasBleeding: true = true

Is texture bleeding from the texture atlas prevented by default?

defaultPreventBleeding: true = true

Is texture bleeding from old content prevented by default?

defaultRegisterKeyboardDriver: true = true

Are keyboard drivers auto-registered by default?

defaultRegisterPointerDriver: true = true

Are pointer drivers auto-registered by default?

defaultResolution: 1 = 1

The resolution of the canvas. For example, if 2, then the resolution of the canvas will be doubled. If 0.5, then the resolution of the canvas will be halved.

defaultUnitsPerPixel: 0.02 = 0.02

Default units-per-pixel

Accessors

  • get canvas(): HTMLCanvasElement
  • The Root#viewport's CanvasViewport#canvas | canvas. The canvas must not be modified directly; consider it output-only.

    Returns HTMLCanvasElement

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

    Returns Widget

  • get currentTextInputHandler(): null | TextInputHandler
  • The text input handler that is currently in use. null if none in use.

    See Root#textInputHandler.

    Returns null | TextInputHandler

  • get enabled(): boolean
  • Returns boolean

  • set enabled(enabled): void
  • Parameters

    • enabled: boolean

    Returns void

  • get maxCanvasHeight(): number
  • Returns number

  • set maxCanvasHeight(maxCanvasHeight): void
  • Parameters

    • maxCanvasHeight: number

    Returns void

  • get maxCanvasWidth(): number
  • Returns number

  • set maxCanvasWidth(maxCanvasWidth): void
  • Parameters

    • maxCanvasWidth: number

    Returns void

  • get 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

    Returns null | PointerStyleHandler

  • set pointerStyleHandler(pointerStyleHandler): void
  • Parameters

    Returns void

  • get preventBleeding(): boolean
  • Returns boolean

  • set preventBleeding(preventBleeding): 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): void
  • Parameters

    • resolution: number

    Returns void

  • get pointerDriver(): PointerDriver
  • The shared PointerDriver instance. Getter only. The PointerDriver will only be created when needed. Used for pointer (mouse & XR controller) input.

    Returns PointerDriver

  • get pointerIDs(): Map<Cursor, number>
  • A Map mapping each cursor component to a PointerDriver's pointer ID.

    Returns Map<Cursor, number>

Methods

  • Stop requesting a pointer style.

    Parameters

    • widget: Widget
    • Optional source: unknown

    Returns void

  • Stop requesting all pointer styles from a specific widget.

    Parameters

    Returns void

  • Destroy the texture used by this UI root, or do nothing if there is no texture created. The UI root will still be usable after calling this, as the texture is auto-created when needed.

    Use this if you want to save atlas space for a disabled UI root. If this is your use-case, and the UI root is not frequently toggled, consider using the WLRoot#destroyTextureWhenDisabled option.

    Returns void

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

    Parameters

    Returns void

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

    Parameters

    Returns void

  • Stop assigning a specific widget ID. Must not be called manually.

    Parameters

    • id: string

      The ID to stop assigning

    Returns void

  • Gets the current focus of a given type.

    Parameters

    Returns null | Widget

  • Instantiate a text input handler. Used for mobile or WebXR where keyboard events are hard to get. Note that this will replace the current handler if there is any.

    Parameters

    Returns null | TextInputHandler

    If Root#textInputHandler is set, returns a new instance, otherwise, returns null.

  • Get the widget that an ID is assigned to. If no widget is assigned to a given ID, an error is thrown.

    Parameters

    • id: string

      The ID of the wanted Widget

    Returns Widget

  • Dispose all resources associated with text input handler. You probably don't need to implement this method, unless you do something with the HTML elements returned by the input handler (such as listening to focus or blur events).

    Parameters

    Returns void

  • Handle initialization of a text input handler. You probably don't need to implement this method, unless you do something with the HTML elements returned by the input handler (such as listening to focus or blur events).

    Parameters

    Returns void

  • Mark a widget as hovered (received a pointer event since the last check). Widgets will call this method automatically, there is no need to manually call this.

    Parameters

    Returns void

  • Remove an event listeners added with Root#on. Not chainable.

    Parameters

    Returns boolean

  • Remove an event listeners added with Root#onAny. Not chainable.

    Parameters

    Returns boolean

  • Listen to a specific event with a user listener. Chainable.

    Only events that pass through the Root will be listened; all trickling events that start at the root will be listened, sticky events will only be listened if they are dispatched at the Root, and bubbling events will only be listened if none of the child widgets capture the event.

    Parameters

    • eventType: string

      The WidgetEvent#"type" to listen to

    • listener: WidgetEventListener

      The user-provided callback that will be invoked when the event is listened

    • Optional once: boolean

      Should the listener only be invoked once? False by default

    Returns WLVirtualKeyboardRoot

  • Similar to Root#on, but any event type invokes the user-provided callback, the listener can't be invoked only once, and the listener is called with a lower priority than specific event listeners. Chainable.

    Parameters

    • listener: WidgetEventListener

      The user-provided callback that will be invoked when a event is listened

    Returns WLVirtualKeyboardRoot

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

    Calls Root#viewport's Viewport#paint with Root#child.

    Call this after calling Root#postLayoutUpdate.

    Returns null | Rect[]

    Returns a list of dirty rectangles in the texture's coordinates, or null if the child widget was not repainted. Use this to tell an external 3D library whether to update a mesh's texture or not, and where to update the mesh's texture.

  • 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

  • Request that a specific ID is assigned to a specific Widget that is attached to this Root. Must not be called manually; Widget will automatically manage its ID when needed.

    Parameters

    • id: string

      The wanted ID

    • widget: Widget

      The widget that the ID will be assigned to

    Returns void

  • Request a pointer style. If the pointer style has a lower priority than the current pointer style, it won't be displayed, but will still be queued up in case the higher-priority style is cleared.

    Parameters

    • widget: Widget
    • pointerStyle: string
    • Optional source: unknown

    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

  • Do a full update of this root. Does a pre-layout update, resolves the layout, does a post-layout update and paints. Call this instead of the individual Root update methods.

    Returns void

  • Get the pointer ID assigned to a given cursor component. If the cursor has no pointer ID assigned, a new pointer ID is registered to the PointerDriver.

    Parameters

    • cursor: Cursor

      The cursor component

    Returns number

  • Internal

    Creates a new CanvasViewport instance for a new Root. Normally it wouldn't make sense to separate this from the constructor, but this makes viewport creation hookable, allowing for the creation of debug overlay viewports.

    Parameters

    Returns CanvasViewport

    Returns a new CanvasViewport (or child class instance) for the Root

Generated using TypeDoc