Skip to content

Core widgets: API ​

This page is generated from the willowui source. It lists each public class with its constructor, its setter-style methods and its callback fields. The guide page for this family explains how to use them. Methods the generator skips (internal handlers, layout and draw steps) are still reachable but are not part of the everyday surface.

Component ​

Source: src/core/component.tks.

ts
new Component(name: string)

Callback fields: onFocusChange, onVisualStateChange, onActivate, onLayout, onThemeChange, onTooltipShow, onTooltipHide.

MethodReturnsNotes
setOnActivate(fn: Function | null)void
setOnEvent(name: string, fn: Function)voidRegister a named handler for template on:* bindings.
setZIndex(z: int)void
setUserData(v: any)void
getUserData()any
setInteractable(v: boolean)void
isInteractable()boolean
isDisposed()boolean
isEnabled()boolean
isVisible()boolean
isHovered()boolean
isPressed()boolean
isFocused()boolean
hasAncestor(a: Component)booleanTrue when a is an ancestor of this component.
setHitShape(s: Rect | null)voidThe pointer hit area, in local coordinates; null leaves the node's default bounds.
addRawChild(n: Node | null)voidAdd a raw willow node (a Sprite, Text, ...) that is not a component.
removeRawChild(n: Node | null)void
setPosition(px: float, py: float)voidPosition in the parent's space; keeps the layout fields in step with the node. In a Window body a placed child leaves the flow and keeps this position, while its siblings keep flowing; other layout parents may override it.
setSize(w: float, h: float)voidSize in pixels. Kept in width/height; the node is NOT resized (see the RULE above). An established hit shape follows. Panel overrides this to also fit its background and border.
addToNode(parent: Node | null)voidAdd this component's node under parent and apply pending layout.
addToScene(root: Node | null)voidAdd to the scene root (engine.root2d) and apply pending layout.
setEnabled(v: boolean)void
setVisible(v: boolean)void
bindEnabled(ref: Ref&lt;boolean&gt;)voidFollow a Ref<boolean>; the previous binding is stopped first.
bindVisible(ref: Ref&lt;boolean&gt;)void
setCursorShape(shape: string)void
setTooltip(tt: any)void
setTooltipText(text: string, family: string, size: float)voidA one-label tooltip. Needs the tooltip provider that 7027's tooltip.tks registers.
clearTooltip()void
getTooltip()any
setContextMenu(cm: Showable | null)void
clearContextMenu()void
setOnTooltipShow(fn: Function | null)void
setOnTooltipHide(fn: Function | null)void
setFocused(v: boolean)voidSet the focus state directly; prefer FocusManager.setFocus for proper tracking.
setHandleKey(fn: Function | null)void
addChild(child: Component | null)voidAppend a child. Both the component tree and the node tree are updated.
removeChild(child: Component | null)void
setTheme(t: Theme | null)voidExplicit theme; null reverts to parent inheritance. Propagates to descendants.
setVariant(v: int)void
enableFocusNavigation()voidThe standard focus flags plus registration with the focus manager.
hideBackground()void
hideBorder()void
hideFocusRing()void
applyCornerRadius(r: float)void
applyCornerRadiiPerCorner(tl: float, tr: float, br: float, bl: float)void
applyBackground(bg: Background)void
applyBorder(color: Color, width: float, bg: Background)void
applyFocusRing(color: Color, width: float)voidFocus ring around the whole component; corner radius from the component.
applyFocusRingSize(color: Color, width: float, w: float, h: float)voidLike applyFocusRing, for an interactive area smaller than the component (a checkbox box).
hasBgSliceNodes()boolean
isLayoutDirty()boolean
isDrawDirty()boolean
sizeToContent()voidResize to tightly fit the children (VBox, HBox, Flow), then lay out.
addAnchoredChild(child: Component | null, anchor: int, offsetX: float, offsetY: float)voidAdd a child pinned to anchor with pixel offsets; the layout must be LAYOUT_ANCHOR.
setAnchor(child: Component | null, anchor: int, offsetX: float, offsetY: float)voidChange the anchor and offsets of an existing direct child.

Panel ​

Source: src/core/panel.tks. Extends Component.

ts
new Panel(name: string)
MethodReturnsNotes
applyThemeColors()voidApply the effective theme's PanelGroup unless the aspect is overridden.
setBackground(c: Color)void
setCornerRadii(tl: float, tr: float, br: float, bl: float)voidIndependent corner radii (TL, TR, BR, BL).
setBorder(c: Color, width: float)void
setPadding(top: float, right: float, bottom: float, left: float)void
setLayout(mode: int)void
setSpacing(s: float)void
setAlignment(a: int)void
setJustify(j: int)void
setSize(w: float, h: float)voidSet the size and fit the background, border and hit shape. With a layout mode active, layout runs now so callers see final child positions.

Label ​

Source: src/core/label.tks. Extends Component.

ts
new Label(name: string, text: string, family: string, displaySize: float)
MethodReturnsNotes
text()string
setText(t: string)void
setFont(family: string)voidUse another registered family at the current size.
setBold(bold: boolean)void
setItalic(italic: boolean)void
setFontSize(size: float)voidSet the display size (0 restores the default) and re-measure.
setColor(c: Color)void
setAlign(a: int)voidTEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER or TEXT_ALIGN_RIGHT.
setSharpness(s: float)voidGo writes TextBlock.Sharpness; here it drives willow's Text.sharpness (item 7136).
setWrapWidth(w: float)voidMaximum line width for wrapping; zero means no wrapping.
bindText(ref: Ref&lt;string&gt;)voidFollow a Ref<string>: the label takes the ref's value now and at every later change. Any previous binding is stopped first.

Button ​

Source: src/core/button.tks. Extends Component.

ts
new Button(name: string, text: string, family: string, displaySize: float)
MethodReturnsNotes
setText(t: string)void
bindText(ref: Ref&lt;string&gt;)voidThe label follows the ref; any previous binding is stopped first.
setOnClick(fn: Function | null)void
setSize(w: float, h: float)voidSets the size and disables auto-size.
setAutoSize(v: boolean)void
setEnabled(v: boolean)void
hasOnClickCallback()boolean

IconButton ​

Source: src/core/button.tks. Extends Component.

ts
new IconButton(name: string)
MethodReturnsNotes
setIconKey(key: string)voidThe icon from a sprite key in the effective theme's sprites map; an unknown key clears the icon.
setIconImage(img: any)voidThe icon from a Texture or a TextureRegion (a theme sprite holds either).
setIconTexture(tex: Texture)void
setIconRegion(region: TextureRegion)void
setIconSize(w: float, h: float)voidOverride the icon size; 0, 0 restores the theme size (square).
setLabel(text: string, family: string, size: float)void
setLabelPosition(pos: int)void
setEnabled(v: boolean)void
setActive(v: boolean)voidThe toggle-style active highlight. A bound ref follows the value.
bindActive(ref: Ref&lt;boolean&gt;)voidFollow a Ref<boolean>. Clicking does not toggle the ref; that is the caller's job.
setOnClick(fn: Function | null)void
setSize(w: float, h: float)void
isActive()boolean

Image ​

Source: src/core/image.tks. Extends Component.

ts
new Image(name: string)
MethodReturnsNotes
setRegion(region: TextureRegion | null)voidAn atlas sprite; clears any Texture.
setImage(tex: Texture | null)voidA raw Texture; clears any region. null clears the image.
clearImage()voidLeave the widget empty.
setScaleMode(mode: int)void
setTint(c: Color)void
setAlpha(a: float)voidThe alpha of the tint.
setCornerRadius(r: float)void-1 is a full pill (half the shorter side); 0 is sharp.
setSize(w: float, h: float)void
sizeToContent()voidResize to the image's native pixel size; no effect without an image.

Tooltip ​

Source: src/core/tooltip.tks. Extends Component.

ts
new Tooltip(name: string)
MethodReturnsNotes
applyThemeColors()voidBackground, border and padding from the effective theme's TooltipGroup.
setSize(w: float, h: float)voidExplicit dimensions, bypassing auto-size.
setText(text: string, family: string, size: float)voidReplace all children with one Label showing text.
setShowDelay(frames: int)void
setHideDelay(frames: int)void
setAnchor(a: int)void
setOffset(x: float, y: float)void
setFadeIn(seconds: float)void
setFadeOut(seconds: float)void
setClampToScreen(v: boolean)void
setClampMargin(px: float)void
show(x: float, y: float)voidShow at a screen position, bypassing the hover delay. Hide it with hide().
hide()voidHide at once, bypassing hideDelay and the fade-out.
isShowing()boolean

TooltipManager ​

Source: src/core/tooltip.tks.

Manages tooltip visibility for the scene. A ticker node under the scene root drives tick() once per frame. DEFAULT_TOOLTIP_MANAGER is the singleton every component uses.

MethodReturnsNotes
setScene(s: any)voidCalled on every setScene: hide what is showing and make sure the nodes exist.
showAtPosition(tt: Tooltip, px: float, py: float)voidShow at an explicit position, bypassing hover. Viewport-corner and follow-mouse anchors ignore (x, y) and compute their own.
hideTooltip(tt: Tooltip)void
hideImmediate(fireCallback: boolean)voidHide with no fade. fireCallback false forgets the trigger first, so its hide callback does not run.

ScrollBar ​

Source: src/core/scrollbar.tks. Extends Component.

ts
new ScrollBar(name: string)

Callback fields: onChange.

MethodReturnsNotes
applyThemeColors()void
applyThumbState()void
setScrollPos(v: float)voidClamp to [0, total - view], store, re-place the thumb and report a real change.
setContentSize(total: float, view: float)void
setOrientation(o: int)void
setOnChange(fn: Function | null)void
setSize(w: float, h: float)voidThe bar's dimensions. The node is not resized (RULE 7007); the track and border are, and the hit shape covers the whole bar.
bindScrollPos(ref: Ref&lt;float&gt;)voidFollow a Ref<float>: apply its current value now and every later write (one frame after).

ScrollPanel ​

Source: src/core/scrollpanel.tks. Extends Panel.

ts
new ScrollPanel(name: string)
MethodReturnsNotes
addContent(child: Component | null)voidAdd a component's node to the content node WITHOUT adopting it as a child (Go AddContent).
setContentSize(w: float, h: float)void
setScrollX(v: float)void
setScrollY(v: float)void
scrollTo(x: float, y: float)void
getScrollX()float
getScrollY()float
showVScroll(show: boolean)void
showHScroll(show: boolean)void
setSize(w: float, h: float)void
setBorder(c: Color, width: float)voidA manual border colour and width; the bars and viewport re-fit inside it. (Go passes an empty solid Background so the border is drawn as edges.)
addChild(child: Component | null)voidAdd a child component; its node goes inside the scrollable content container.
removeChild(child: Component | null)voidDetach a child from the content container (the node that holds it, not the panel node).

Screen ​

Source: src/core/controller.tks.

MethodReturnsNotes
add(e: Component)void
addNode(n: Node)void
remove(e: Component)void
removeNode(n: Node)void
isVisible()boolean
show()voidAttach the root node to the scene and call onCreate on first show.
hide()voidDetach the root node but keep all state.
clearTemplateTree()voidStop all tracked refs and remove every child of the root (hot reload).
findByName(name: string)Component | nullThe component with this name in the tree, or null.

StageManager ​

Source: src/core/controller.tks.

A stack of screens.

MethodReturnsNotes
setScene(s: Node | null)voidSet the scene root used to attach screens; screens without one adopt it.
add(screen: Screen)voidPush and show.
remove(screen: Screen)voidDispose and remove a specific screen.
closeAll()void
size()int