Optional
properties: Readonly<TextInputProperties>Private
_editingTextInput#editingEnabled but for internal use.
Protected
_flexWidget#flex but for internal use.
Protected
_flexWidget#flexBasis but for internal use.
Protected
_flexWidget#flexShrink but for internal use.
Protected
_layoutIf this is true, widget needs their layout resolved. If implementing a container, propagate this up.
Protected
_maxWidget#maxHeight but for internal use.
Protected
_maxWidget#maxWidth but for internal use.
Protected
_minWidget#minHeight but for internal use.
Protected
_minWidget#minWidth but for internal use.
Protected
_parentThe parent Widget of this widget.
Widgets not Widget#attached to a UI tree will have this property set to null, but root widgets will also have a null parent.
Protected
_rootThe Root that this widget is currently inside.
Widgets not Widget#attached to a UI tree will have this property set to null.
Protected
_viewportThe Viewport that this widget is currently painting to. A UI tree can have multiple Viewports due to ViewportWidget, so this is not equivalent to Root#viewport.
Widgets not Widget#attached to a UI tree will have this property set to null.
Private
blinkAt what timestamp did the blinking start. If 0, then the text cursor is not blinking.
Private
blinkWas the cursor shown last frame due to blinking? If null, then the text cursor is not blinking.
Private
Readonly
callbackThe callback used for the TextInput#"variable"
Protected
currentCurrent text input handler. Make sure to call TextInputHandler#dismiss if you want to get rid of it; don't just set this to null.
Private
cursorCurrent cursor offset in pixels.
Private
cursorDoes the cursor offset need to be updated?
Private
cursorCurrent cursor position (index, not offset).
Private
draggingIs the pointer dragging?
Private
dragThe cursor position when dragging was started. Used for double/triple-click dragging.
Protected
heightHeight of widget in pixels.
Is the text hidden?
Protected
idealThe ideal height of the widget in pixels. See Widget#width.
Protected
idealThe ideal width of the widget in pixels; if non-integer widget dimensions were allowed, the widget would have this size. Use this for layout calculations, but never use this for painting so that subpixel issues are avoided.
Protected
idealXThe ideal absolute horizontal offset of the widget in pixels; if non-integer positions were allowed, the widget would have this position. Use this for layout calculations, but never use this for painting so that subpixel issues are avoided.
Protected
idealYThe ideal absolute vertical offset of the widget in pixels. See Widget#x.
An input filter; a function which dictates whether a certain input can be inserted in the text. If the function returns false given the input, then the input will not be inserted in the text. Useful for preventing newlines or forcing numeric input. Note that the input is not neccessarily a character; it can be a whole sentence.
Private
lastWhen was the last pointer click? For detecting double/triple-clicks
Private
needsShould the caret position be auto-scrolled after the layout is finalized?
Private
offsetCurrent offset of the text in the text box. Used on overflow.
Private
selectCurrent cursor selection start offset in pixels.
Private
selectCurrent cursor selection start position (index, not offset).
Private
successiveHow many clicks have there been after a first click where the time between each click is less than 500 ms. Used for detecting double/triple clicks
Protected
tabCan this widget be focused by pressing tab?
Is tab mode enabled? When enabled, pressing the tab key will type a tab character instead of changing focus.
Toggled automatically by pressing ctrl+m, but can be manually toggled by changing this flag. If the TextInput grabs the keyboard focus, then this is automatically disabled so that user flow isn't unexpectedly interrupted.
Does nothing if TextInput#typeableTab is disabled.
Protected
textThe helper for measuring/painting text
Can tab characters be typed in this input widget? If true, then pressing tab will not move the focus to the next widget, unless tab is a filtered character.
If tab is not a filtered character and this is true, holding shift will move to the next widget instead of typing the character, not move to the previous focusable widget.
Readonly
variableThe helper for keeping track of the text value. If it's not a validated box, then it will be assumed to always be valid.
Protected
widthWidth of widget in pixels.
Is text wrapping enabled? If not, text will be panned if needed
Protected
xAbsolute horizontal offset of widget in pixels.
Protected
yAbsolute vertical offset of widget in pixels.
Static
autoXMLInput mapping for automatically generating a widget factory for a BaseXMLUIParser with BaseXMLUIParser#autoRegisterFactory. If null, then BaseXMLUIParser#registerFactory must be manually called by the user.
This static property must be overridden by a concrete child class if you want to provide auto-factory support.
The accent fill style. Usually a saturated colour more saturated than ThemeProperties#primaryFill used for highlighting boxes which use PrimaryFill.
The accent fill style. Usually a saturated colour more saturated than ThemeProperties#primaryFill used for highlighting boxes which use PrimaryFill.
Is the Widget attached to a UI tree, enabled and in a UI sub-tree where all ascendants are enabled?
Can only be updated by calling Widget#updateActiveState, although this should never be done manually; only done automatically by container Widgets and Roots.
Check if this Widget is attached to a UI tree. If not, then this Widget must not be used. Must not be overridden.
The background fill style. Used for widgets with a background (as in, a background above the canvas background).
The background fill style. Used for widgets with a background (as in, a background above the canvas background).
The background glow fill style. Used for highlighting boxes which use ThemeProperties#backgroundFill.
The background glow fill style. Used for highlighting boxes which use ThemeProperties#backgroundFill.
Is the text cursor shown?
Returns true if the text cursor is shown, false if not shown but the text input is in use, or null if the text cursor is not shown due to the text input not being in use.
The blink rate of text cursors in text input widgets like TextInput. Value in "blinks" per second.
The blink rate of text cursors in text input widgets like TextInput. Value in "blinks" per second.
The default text alignment mode of body text (most regular text).
The default text alignment mode of body text (most regular text).
The fill style used for body text (most regular text).
The fill style used for body text (most regular text).
The font style used for body text (most regular text).
The font style used for body text (most regular text).
The height of each line of text in body text (most regular text). If null, it will be automatically detected.
The height of each line of text in body text (most regular text). If null, it will be automatically detected.
The spacing between each line of text in body text (most regular text). If null, it will be automatically detected.
The spacing between each line of text in body text (most regular text). If null, it will be automatically detected.
The canvas background fill style.
The canvas background fill style.
Protected
caretSimilar to TextInput#caretRect, but uses absolute positions.
Protected
caretSimilar to TextInput#caretRect, but gets bounds instead.
Protected
caretThe alignment in Container for when there is extra space.
The alignment in Container for when there is extra space.
The side length of a text cursor's indicator in pixels. For now there is only a tab mode indicator.
The side length of a text cursor's indicator in pixels. For now there is only a tab mode indicator.
The thickness of a text cursor in pixels.
The thickness of a text cursor in pixels.
Check if the widget has zero width or height. If true, then Widget#paint will do nothing, which usually happens when containers overflow.
Get the resolved dimensions. Returns a 2-tuple containing Widget#width and Widget#height.
Use Widget#idealDimensions for layout calculations.
Get the text as it is shown. If the text is hidden, all characters are replaced with a black circle.
Is editing enabled?
If changed, the whole widget is marked as dirty. If disabled, blinking stops and the cursor position is reset to the beginning.
Is this widget enabled? If it isn't, it will act as if it doesn't exist, but will still be present in the UI tree.
Protected
fallbackThe fallback theme. If this theme has a missing property, the fallback theme's property will be used instead. This will automatically (un)subscribe to/from the fallback theme.
How much this widget will expand relative to other widgets in a flexbox container. If changed, sets Widget#_layoutDirty to true.
The starting length of this widget when inside a flexbox, which overrides
the intrinsic length of this widget (the natural length of the content).
If null
(default), then the widget's intrinsic length will be used. If
changed, sets Widget#_layoutDirty to true.
Note that, if set, minimum and maximum self-constraints will still be respected.
How much this widget will shrink relative to other widgets in a flexbox container if the maximum size is exceeded. If changed, sets Widget#_layoutDirty to true.
The unique ID of this Widget. If the Widget has no ID, this value will be null. Uniqueness is tested per-UI tree; ID uniqueness is enforced when the ID is changed or when the Widget is attached to a Root.
If the ID is already taken, setting the ID will have no effect and an error will be thrown.
Similar to Widget#bounds, but uses ideal values
Get the resolved ideal dimensions. Returns a 2-tuple containing Widget#idealWidth and Widget#idealHeight.
Use this for layout calculations, and Widget#dimensions for painting.
Get the resolved ideal position. Returns a 2-tuple containing Widget#idealX and Widget#idealY.
Use this for layout calculations, and Widget#position for painting.
Similar to Widget#rect, but uses ideal values
The inherited theme of this widget. Sets BaseTheme#fallbackTheme.
The background fill style used for input widgets like TextInput.
The background fill style used for input widgets like TextInput.
The background fill style used for input widgets like TextInput when text is selected.
The background fill style used for input widgets like TextInput when text is selected.
The fill style used for text in input widgets like TextInput.
The fill style used for text in input widgets like TextInput.
The fill style used for text in input widgets like TextInput when disabled.
The fill style used for text in input widgets like TextInput when disabled.
The fill style used for text in input widgets like TextInput when invalid.
The fill style used for text in input widgets like TextInput when invalid.
The font style used for text in input widgets like TextInput.
The font style used for text in input widgets like TextInput.
The height of each line of text in input widgets like TextInput. If null, it will be automatically detected.
The height of each line of text in input widgets like TextInput. If null, it will be automatically detected.
The spacing between each line of text in input widgets like TextInput. If null, it will be automatically detected.
The spacing between each line of text in input widgets like TextInput. If null, it will be automatically detected.
Check if the widget's layout is dirty. Returns Widget#_layoutDirty.
The current line number, starting from 0.
Maximum height of widget. Defaults to Infinity. If changed, sets Widget#_maxHeight to true.
Maximum width of widget. Defaults to Infinity. If changed, sets Widget#_maxWidth to true.
The fill style to use when media fails to load.
The fill style to use when media fails to load.
Minimum height of widget. Defaults to 0. If changed, sets Widget#_minHeight to true.
Minimum width of widget. Defaults to 0. If changed, sets Widget#_minWidth to true.
The alignment in MultiContainer for when there is unused space.
The alignment in MultiContainer for when there is unused space.
The spacing length between widgets in MultiContainer.
The spacing length between widgets in MultiContainer.
Similar to Widget#_parent, but throws an error if the widget is not Widget#attached.
Get the resolved position. Returns a 2-tuple containing Widget#x and Widget#y.
Use Widget#idealPosition for layout calculations.
The primary fill style. Usually a saturated colour used for filling boxes that need to stand out.
The primary fill style. Usually a saturated colour used for filling boxes that need to stand out.
Similar to ThemeProperties#checkboxInnerPadding, but for RadioButton.
Similar to ThemeProperties#checkboxInnerPadding, but for RadioButton.
Similar to ThemeProperties#checkboxLength, but for RadioButton.
Similar to ThemeProperties#checkboxLength, but for RadioButton.
Similar to Widget#_root, but throws an error if the widget is not Widget#attached.
The radii to be used for rounding corners in RoundedCorners.
The radii to be used for rounding corners in RoundedCorners.
The radii to be used for rounding corners in ScrollableViewportWidget scrollbars.
The radii to be used for rounding corners in ScrollableViewportWidget scrollbars.
The minimum length of the filled part of a ScrollableViewportWidget's scrollbar in percentage of total length.
The minimum length of the filled part of a ScrollableViewportWidget's scrollbar in percentage of total length.
The minimum length of the filled part of a ScrollableViewportWidget's scrollbar in pixels.
The minimum length of the filled part of a ScrollableViewportWidget's scrollbar in pixels.
The Padding used in ScrollableViewportWidget scrollbars.
The Padding used in ScrollableViewportWidget scrollbars.
The thickness of a ScrollableViewportWidget's scrollbar in pixels.
The thickness of a ScrollableViewportWidget's scrollbar in pixels.
The current text value.
Should not be used internally as a setter (but using it as a getter is fine); if you are extending TextInput, use this.variable.value instead.
The fill style to paint a TooltipContainer's background with.
The fill style to paint a TooltipContainer's background with.
The Padding used in TooltipContainer.
The Padding used in TooltipContainer.
The radii to be used for rounding corners in TooltipContainer.
The radii to be used for rounding corners in TooltipContainer.
Similar to Widget#_viewport, but throws an error if the widget is not Widget#attached.
Protected
activateCalled after the Widget is attached to a UI tree, its parent is
Widget#active (or Root is enabled if this is the top
Widget), and the Widget itself is enabled; only called when all of the
previous conditions are fulfilled, not when one of the conditions is
fulfilled. Should be overridden for resource management, but
super.activate
must be called.
Must not be propagated to children by container Widgets. This is already done automatically by Widget#updateActiveState.
Marks Widget#layoutDirty as true, and marks the whole widget as dirty.
Called when the Widget is attached to a UI tree. Must never be overridden. See Widget#handleAttachment instead.
If the widget is already in a UI tree (already has a parent or is the root Widget, both checked via Widget#attached), then this method will throw an exception; a Widget cannot be in multiple UI trees.
The Root of the UI tree
The Viewport in this part of the UI tree. A UI tree can have multiple nested Viewports due to ViewportWidget
The new parent of this Widget. If null
, then this Widget has no parent and is the root Widget
Auto-scroll to this widget. Uses the whole widget as the auto-scroll bounds.
Private
autoAuto-scroll to the caret if the caret is shown.
Protected
clearClear the pointer style from the currently attached Root.
Convenience method, which just calls Root#clearPointerStyle with
this
as the Widget.
Optional
source: unknownProtected
deactivateCalled when the Widget is no longer Widget#active. Should be
overridden for resource management, but super.deactivate
must be
called.
Must not be propagated to children by container Widgets. This is already done automatically by Widget#updateActiveState.
Marks Widget#layoutDirty as true and drops all foci set to this Widget if the Widget is attached.
Deletes a certain amount of characters in a given direction from the current cursor index. Calls TextInput#deleteRange or TextInput#moveCursorTo if neccessary. If text is being selected, delta is ignored and the selection is deleted instead. Note that a delta of zero doesn't delete anything.
The amount and direction of the deletion. For example, if 5, then 5 characters are deleted after the cursor. If -5, then 5 characters are deleted before the cursor and the cursor is moved 5 indices left.
Like TextInput#moveCursorWord, but for deleting words. Calls TextInput#moveCursorWord and TextInput#deleteRange. If text is being selected, delta is ignored and the selection is deleted instead. Note that a delta of zero doesn't delete anything.
Called when the Widget is detached from a UI tree. Must never be overridden. See Widget#handleDetachment instead.
Sets Widget#_root, Widget#_viewport and Widget#_parent to null.
Drops all foci set to this Widget.
If the widget was not in a UI tree, then an exception is thrown.
Called when an event is passed to the Widget. Must not be overridden.
Dispatches to user event listeners first; if a user listener captures the
event, then this
is returned.
For trickling events: Checks if the target matches the Widget, unless the Widget propagates events, or if the event is a PointerEvent and is in the bounds of the Widget. If neither of the conditions are true, the event is not captured (null is returned), else, the Widget#handleEvent method is called and its result is returned.
For bubbling or sticky events: Passes the event to the handleEvent method and returns the result.
Returns the widget that captured the event or null if none captured the event.
Sets Widget#x, Widget#y, Widget#width and Widget#y from Widget#idealX, Widget#idealY, Widget#idealWidth and Widget#idealHeight by rounding them. If the final values have changed, Widget#markWholeAsDirty is called.
Can be overridden, but super.finalizeBounds
must still be called; if
you have parts of the widget that can be pre-calculated when the layout
is known, such as the length and offset of a Checkbox,
then this is the perfect method to override, since it's only called after
the layout is resolved to final (non-ideal) values, is only called if
needed (unlike postLayoutUpdate, which is always called after the
layout phase) and can be used to compare old and new positions and
dimensions.
Abstract container widgets such as Parent must always override
this and call finalizeBounds
on each child widget.
Protected
handleCalled when the Widget is attached to a UI tree. Must be overridden by
container widgets to attach children or for resource management, but
child.attach
must be called instead of child.handleAttachment
.
Note that, to call attach
on a child widget, you need a root, viewport
and parent. The parent would be this
, but the root and viewport are not
passed to this method, unlike in attach
. This is because most of the
time you won't be implementing a container widget, so these parameters
are just an unnecessary hassle. Get them from this.root
and
this.viewport
instead (or this._root
and this._viewport
),
respectively.
super.handleAttachment
doesn't have to be called and does nothing by
default, unless you are deriving a class that has overridden this method.
If you're not sure, it's safe to call super anyway.
Protected
handleProtected
handleCalled when the Widget is detached from a UI tree. Must be overridden by
container widgets to detach children or for resource management, but
child.detach
must be called instead of child.handleDetachment
.
super.handleDetachment
doesn't have to be called and does nothing by
default, unless you are deriving a class that has overridden this method.
If you're not sure, it's safe to call super anyway.
Protected
handleWidget event handling callback. If the event is to be captured, the capturer is returned, else, null.
By default, this will do nothing and capture the event if it is targeted at itself. Bubbling events will be automatically dispatched to the parent or root. Sticky events will be ignored.
If overriding, return the widget that has captured the event (could be
this
, for example, or a child widget if implementing a container), or
null if no widget captured the event. Make sure to not capture any events
that you do not need, or you may have unexpected results; for example, if
you capture all dispatched events indiscriminately, a
TabSelectEvent event may be captured and result in weird
behaviour when the user attempts to use tab to select another widget.
Parent widgets should dispatch TricklingEvents to children. All widgets should dispatch BubblingEvents to the Widget#parent or Widget#root, if available. StickyEvents should never be dispatched to children or parents.
Note that bubbling events captured by a Root will return null, since there is no capturing Widget.
Since the default handleEvent implementation already correctly handles bubbling and sticky events, it's a good idea to call super.handleEvent on these cases to avoid rewriting code, after transforming the event if necessary.
Protected
handleWidget painting callback. Should be overridden; does nothing by default. Do painting logic here when extending Widget.
It's safe to repaint the whole widget even if only a part of the widget is damaged, since the painting is automatically clipped to the damage regions, however, it's preferred to only repaint the damaged parts for performance reasons.
All passed dirty rectangles intersect the widget, have an area greater than 0, and are clamped to the widget bounds.
The painting logic of this widget can modify the rendering context in a way that changes rendering for its children, however, the context must be kept clean for the parent of this widget; operations like clipping for children are OK, but make sure to restore the context to a state with no clipping when the painting logic is finished. This does not apply to some basic context properties such as fillStyle or strokeStyle; you are expected to set these on every handlePainting, do not assume the state of these properties.
Protected
handleProtected
handleProtected
handleResolve dimensions of this widget. Must be implemented; set Widget#width and Widget#height.
Private
hideTextInput#hideText watcher callback method. Sets TextInput#cursorOffsetDirty and marks the whole widget as dirty.
Insert text at the current cursor index. Calls TextInput#moveCursorTo afterwards.
Protected
markMark a part of this widget as dirty. The dirty rectangle will be propagated via ascendant widgets until it reaches a CanvasViewport.
If the widget is not active, then this method call is ignored.
Must not be overridden; you probably want to override Widget#propagateDirtyRect instead.
Private
markProtected
markMark the entire widget as dirty. Convenience method that calls Widget#markAsDirty.
Move the cursor by a given index delta. Calls TextInput#moveCursorTo
The change in index; if a positive number, the cursor will be moved right by that amount, else, the cursor will be moved left by that amount.
Move the cursor to the end of the line. Calls TextInput#moveCursorTo
Move the cursor given a given pointer offset.
The horizontal offset in pixels, relative to the text area with padding removed
The vertical offset in pixels, relative to the text area with padding removed
Should this do text selection?
Move the cursor by a given line delta. Calls TextInput#moveCursorFromOffset
The change in line; if a positive number, the cursor will be moved down by that amount, else, the cursor will be moved up by that amount.
Move the cursor to the start of the line. Calls TextInput#moveCursorTo
Move the cursor to a given index.
Marks the widget as dirty and sets TextInput#cursorOffsetDirty to true.
Should this do text selection?
Move the cursor by skipping over a number of words. Calls TextInput#moveCursorTo
The change in words; if a positive number, the cursor skip this amount of words, else, it will do the same, but backwards.
Remove an event listeners added with Widget#on. Not chainable.
The WidgetEvent#"type" to stop listening to
The user-provided callback that was used in Widget#on
Was the listener only meant to be invoked once? Must match what was used in Widget#on
Remove an event listeners added with Widget#onAny. Not chainable.
The user-provided callback that was used in Widget#onAny
Listen to a specific event with a user listener. Only events that pass through this widget will be listened. Chainable.
The WidgetEvent#"type" to listen to
The user-provided callback that will be invoked when the event is listened
Should the listener only be invoked once? False by default
Similar to Widget#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.
The user-provided callback that will be invoked when a event is listened
Protected
onCalled when the fallback theme changes. Does nothing by default.
The property name of the theme property that was updated. If a general theme update, then this will be null and all theme properties should be treated as changed.
Called when the Widget needs to be re-painted and the Root is being rendered. Does nothing if none of the dirty rectangles intersect the widget or the widget is Widget#dimensionless, else, calls the Widget#handlePainting method. Must not be overridden.
The damaged regions that need to be re-painted, as a list of dirty rectangles
Generic update method which is called after layout is resolved. Calls Widget#handlePostLayoutUpdate if widget is enabled. Must not be overridden.
Generic update method which is called before layout is resolved. Calls Widget#handlePreLayoutUpdate if widget is enabled. Must not be overridden.
Propagate a dirty rectangle from a child widget to the parent.
Should be overridden by Widgets that transform their children, to correct the position and dimensions of the dirty rectangle.
Query the position of a point as if it were in the same coordinate origin as an ascendant widget (or the root). Call this from a child widget.
Useful for reversing transformations made by ascendant widgets.
Must be overridden by widgets that transform children or that have a different coordinate origin.
Query the position of a point as if it were in the same coordinate origin as an ascendant widget (or the root).
Useful for reversing transformations made by ascendant widgets.
Must not be overridden.
Query the position and dimensions of a rectangle as if it were in the same coordinate origin as an ascendant widget (or the root). Call this from a child widget.
Useful for reversing transformations made by ascendant widgets.
Must be overridden by widgets that transform children or that have a different coordinate origin.
Protected
requestRequest a pointer style from the currently attached Root.
Convenience method, which just calls Root#requestPointerStyle
with this
as the Widget.
Optional
source: unknownProtected
requestWrapper for Widget#handleResolveDimensions. Does nothing if Widget#enabled is false. If the resolved dimensions change, the widget is marked as dirty. Widget#_layoutDirty is set to false. If the widget is not loose and the layout has non-infinite max constraints, then the widget is stretched to fit max constraints. Must not be overridden.
Set the ideal position of this widget (Widget#idealX and Widget#idealY). Does not set any flags of the widget.
Can be overridden, but super.resolvePosition
must always be called, and
the arguments must be preserved. Container widgets should override this
method such that resolvePosition
is called for each child of the
container.
Private
selectUpdate the Widget#active state of the Widget. If the active state
changes from false
to true
, then Widget#activate is called.
If the active state changes from true
to false
, then
Widget#deactivate is called.
Container Widgets must override this so that the active state of each
child is updated, but super.updateActiveState
must still be called.
Each child's active state must only be updated if the container's active
state changed; this is indicated by the return value of this method.
Returns true if the active state changed.
A flexbox widget that allows for a single line of text input.
Supports obscuring the text with TextInput#hideText, which shows all characters as black circles like in password fields, text validation and toggling editing.
If a TextInputHandler is set, then that will be used instead of keyboard input for mobile compatibility.