Creates a new Root.
Sets child, pointerStyleHandler and child's inherited theme.
Optional
properties: Readonly<RootProperties>Protected
_currentProtected
_enabledIs the Root enabled? For internal use only.
See enabled
Protected
_fociCurrent component foci (event targets for each focus type).
For internal use only.
See requestFocus, dropFocus, clearFocus and getFocus
Protected
_fociLast capturer of each component focus (event targets for each focus type).
For internal use only.
See getFocusCapturer
Protected
_mobileIs the mobile-friendly text input in use?
For internal use only.
See hasMobileTextInput, usingMobileTextInput and getTextInput
Protected
driversThe list of drivers registered to this root
The pointer style this root wants. Will be set on postLayoutUpdate by 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
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
Protected
viewportThe internal viewport. Manages drawing
Static
Private
badHas the warning for poorly captured TabSelect events been issued?
The viewport's canvasDimensions
The viewport's constraints
The child's dimensions
Get the scale used for the viewport. The horizontal and/or vertical scale may not be 1 if maxCanvasWidth or maxCanvasHeight are exceeded.
Note that this is only valid after resolving child's layout.
Equivalent to getting effectiveScale on viewport.
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
Can getTextInput be called? True if textInputHandler is not null and usingMobileTextInput is false.
Shortcut for viewport's maxCanvasHeight property
Shortcut for viewport's maxCanvasWidth property
Shortcut for viewport's preventBleeding property.
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.
Is getTextInput in use?
See _mobileTextInUse.
Unregisters all drivers from the root, by calling unregisterDriver.
Clears the current focus of a given type. If there was a focus set, drivers are notified by calling onFocusChanged.
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.
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 true if the event was captured
Clears the current focus of a given type if it is currently set to a given widget. Achieved by calling clearFocus.
Gets the last focus capturer of a given type.
Get text input from the user. Used for mobile where keyboard events are hard to get.
If this is already in use (usingMobileTextInput), returns null, else, returns a string typed by the user.
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 whether the child was dirty or not. Use this to tell an external 3D library whether to update a mesh's texture or not.
Do a post-layout update; calls child's postLayoutUpdate and updatePointerStyle. Does nothing if root is disabled.
Call this before calling paint and after calling resolveLayout
Do a pre-layout update; calls drivers' update and child's preLayoutUpdate. Does nothing if root is disabled.
Call this before calling resolveLayout
Sets the current focus of a given type to a given widget. If the focus changes, clearFocus is called and drivers are notified by calling onFocusChanged.
Resolve the layout of this root. Does nothing if root is disabled.
Calls viewport's resolveLayout with child
Call this before calling postLayoutUpdate and after calling preLayoutUpdate
Returns true if the viewport was resized or re-scaled
Calls pointerStyleHandler if the pointerStyle has changed (checked by comparing with _currentPointerStyle). Also updates _currentPointerStyle. Can also be optionally supplied a new pointer style.
Generated using TypeDoc
A Root is the parent of all widgets, but not a widget itself. It contains a single child and manages dimensions and input handling