Widget is the base class for all UI widgets.
See docLib for details.
Slots
- addSource
-
virtual This add(Widget? child)
Add a child widget. If child is null, then do nothing. If child is already parented throw ArgErr. Return this.
-
private native Void attach()
Attach to a native peer
-
private native Bool attached()
Is this widget attached to a native peer?
- boundsSource
-
Rect bounds
Position and size of this widget relative to its parent. If this a window, this is the position on the screen.
-
internal native Void checkFocusListeners()
-
internal native Void checkKeyListeners()
- childrenSource
-
Widget[] children()
Get the children widgets.
-
private native Void detach()
Detach from native peer
- eachSource
-
Iterate the children widgets.
- enabledSource
-
native Bool enabled
Enabled is used to control whether this widget can accept user input. Disabled controls are "grayed out".
- focusSource
-
native Void focus()
Attempt for this widget to take the keyboard focus.
- hasFocusSource
-
native Bool hasFocus()
Return if this widget is the focused widget which is currently receiving all keyboard input.
-
new make()
- onBlurSource
-
@transient
readonly EventListeners onBlur := EventListeners()Callback for focus lost event on this widget.
Event id fired:
Event fields:
- none
- onFocusSource
-
@transient
readonly EventListeners onFocus := EventListeners()Callback for focus gained event on this widget.
Event id fired:
Event fields:
- none
- onKeyDownSource
-
@transient
readonly EventListeners onKeyDown := EventListeners()Callback for key pressed event on this widget. To cease propagation and processing of the event, then
consume
it.Event id fired:
Event fields:
Event.keyChar
: unicode character represented by key eventEvent.key
: key code including the modifiers
- onKeyUpSource
-
@transient
readonly EventListeners onKeyUp := EventListeners()Callback for key released events on this widget. To cease propagation and processing of the event, then
consume
it.Event id fired:
Event fields:
Event.keyChar
: unicode character represented by key eventEvent.key
: key code including the modifiers
- onMouseDownSource
-
@transient
readonly EventListeners onMouseDown := EventListeners()Callback for mouse button pressed event on this widget.
Event id fired:
Event fields:
Event.pos
: coordinate of mouseEvent.count
: number of clicksEvent.key
: key modifiers
- onMouseEnterSource
-
@transient
readonly EventListeners onMouseEnter := EventListeners()Callback when mouse enters this widget's bounds.
Event id fired:
Event fields:
Event.pos
: coordinate of mouse
- onMouseExitSource
-
@transient
readonly EventListeners onMouseExit := EventListeners()Callback when mouse exits this widget's bounds.
Event id fired:
Event fields:
Event.pos
: coordinate of mouse
- onMouseHoverSource
-
@transient
readonly EventListeners onMouseHover := EventListeners()Callback when mouse hovers for a moment over this widget.
Event id fired:
Event fields:
Event.pos
: coordinate of mouse
- onMouseMoveSource
-
@transient
readonly EventListeners onMouseMove := EventListeners()Callback when mouse moves over this widget.
Event id fired:
Event fields:
Event.pos
: coordinate of mouse
- onMouseUpSource
-
@transient
readonly EventListeners onMouseUp := EventListeners()Callback for mouse button released event on this widget.
Event id fired:
Event fields:
Event.pos
: coordinate of mouseEvent.count
: number of clicksEvent.key
: key modifiers
- onMouseWheelSource
-
@transient
readonly EventListeners onMouseWheel := EventListeners()Callback when mouse wheel is scrolled and this widget has focus.
Event id fired:
Event fields:
Event.pos
: coordinate of mouseEvent.count
: positive or negative number of scroll
- packSource
-
native This pack()
Set this widget's size to its preferred size. Return this.
- parentSource
-
@transient
readonly Widget? parentGet this widget's parent or null if not mounted.
- posSource
-
Position of this widget relative to its parent. If this a window, this is the position on the screen.
- posOnDisplaySource
-
native Point? posOnDisplay()
Get the position of this widget on the screen coordinate's system. If not on mounted on the screen then return null.
- prefSizeSource
-
virtual native Size prefSize(Hints hints := Hints.defVal)
Compute the preferred size of this widget. The hints indicate constraints the widget should consider in its calculations. If no constraints are known for width, then
hints.w
will be null. If no constraints are known for height, thenhints.h
will be null. - relayoutSource
-
native This relayout()
Relayout this widget. This method is called when something has changed and we need to recompute the layout of this widget's children. Return this.
- removeSource
-
virtual This remove(Widget? child)
Remove a child widget. If child is null, then do nothing. If this widget is not the child's current parent throw ArgErr. Return this.
- removeAllSource
-
virtual This removeAll()
Remove all child widgets. Return this.
- repaintSource
-
native Void repaint(Rect? dirty := null)
Repaint this widget. If the dirty rectangle is null, then the whole widget is repainted.
- sizeSource
-
Size of this widget.
- visibleSource
-
native Bool visible
Controls whether this widget is visible or hidden.
- windowSource
-
Window? window()
Get this widget's parent window or null if not mounted under a Window widget.