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.
-
internal Widget[] kids := Widget[,]
- onBlurSource
-
readonly EventListeners onBlur := ...
Callback for focus lost event on this widget.
Event id fired:
Event fields:
- none
- onFocusSource
-
readonly EventListeners onFocus := ...
Callback for focus gained event on this widget.
Event id fired:
Event fields:
- none
- onKeyDownSource
-
readonly EventListeners onKeyDown := ...
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
-
readonly EventListeners onKeyUp := ...
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
- onLayoutSource
-
virtual Void onLayout()
Handle the layout event. The method is only called Pane containers. Custom panes must override this method to set the bounds on all their children.
- onMouseDownSource
-
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
-
readonly EventListeners onMouseEnter := EventListeners()
Callback when mouse enters this widget's bounds.
Event id fired:
Event fields:
Event.pos
: coordinate of mouse
- onMouseExitSource
-
readonly EventListeners onMouseExit := EventListeners()
Callback when mouse exits this widget's bounds.
Event id fired:
Event fields:
Event.pos
: coordinate of mouse
- onMouseHoverSource
-
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
-
readonly EventListeners onMouseMove := EventListeners()
Callback when mouse moves over this widget.
Event id fired:
Event fields:
Event.pos
: coordinate of mouse
- onMouseUpSource
-
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
-
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
- onPaintSource
-
virtual Void onPaint(Graphics g)
This callback is invoked when the widget should be repainted. The graphics context is initialized at the widget's origin with the clip bounds set to the widget's size.
- packSource
-
native This pack()
Set this widget's size to its preferred size. Return this.
- parentSource
-
readonly Widget? parent
Get this widget's parent or null if not mounted.
- posSource
-
native Point pos
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.def)
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
-
native Size size
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.