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.
| Method | Returns | Notes |
|---|---|---|
setOnActivate(fn: Function | null) | void | |
setOnEvent(name: string, fn: Function) | void | Register 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) | boolean | True when a is an ancestor of this component. |
setHitShape(s: Rect | null) | void | The pointer hit area, in local coordinates; null leaves the node's default bounds. |
addRawChild(n: Node | null) | void | Add a raw willow node (a Sprite, Text, ...) that is not a component. |
removeRawChild(n: Node | null) | void | |
setPosition(px: float, py: float) | void | Position 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) | void | Size 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) | void | Add this component's node under parent and apply pending layout. |
addToScene(root: Node | null) | void | Add to the scene root (engine.root2d) and apply pending layout. |
setEnabled(v: boolean) | void | |
setVisible(v: boolean) | void | |
bindEnabled(ref: Ref<boolean>) | void | Follow a Ref<boolean>; the previous binding is stopped first. |
bindVisible(ref: Ref<boolean>) | void | |
setCursorShape(shape: string) | void | |
setTooltip(tt: any) | void | |
setTooltipText(text: string, family: string, size: float) | void | A 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) | void | Set the focus state directly; prefer FocusManager.setFocus for proper tracking. |
setHandleKey(fn: Function | null) | void | |
addChild(child: Component | null) | void | Append a child. Both the component tree and the node tree are updated. |
removeChild(child: Component | null) | void | |
setTheme(t: Theme | null) | void | Explicit theme; null reverts to parent inheritance. Propagates to descendants. |
setVariant(v: int) | void | |
enableFocusNavigation() | void | The 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) | void | Focus ring around the whole component; corner radius from the component. |
applyFocusRingSize(color: Color, width: float, w: float, h: float) | void | Like applyFocusRing, for an interactive area smaller than the component (a checkbox box). |
hasBgSliceNodes() | boolean | |
isLayoutDirty() | boolean | |
isDrawDirty() | boolean | |
sizeToContent() | void | Resize to tightly fit the children (VBox, HBox, Flow), then lay out. |
addAnchoredChild(child: Component | null, anchor: int, offsetX: float, offsetY: float) | void | Add a child pinned to anchor with pixel offsets; the layout must be LAYOUT_ANCHOR. |
setAnchor(child: Component | null, anchor: int, offsetX: float, offsetY: float) | void | Change the anchor and offsets of an existing direct child. |
Panel
Source: src/core/panel.tks. Extends Component.
ts
new Panel(name: string)| Method | Returns | Notes |
|---|---|---|
applyThemeColors() | void | Apply the effective theme's PanelGroup unless the aspect is overridden. |
setBackground(c: Color) | void | |
setCornerRadii(tl: float, tr: float, br: float, bl: float) | void | Independent 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) | void | Set 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)| Method | Returns | Notes |
|---|---|---|
text() | string | |
setText(t: string) | void | |
setFont(family: string) | void | Use another registered family at the current size. |
setBold(bold: boolean) | void | |
setItalic(italic: boolean) | void | |
setFontSize(size: float) | void | Set the display size (0 restores the default) and re-measure. |
setColor(c: Color) | void | |
setAlign(a: int) | void | TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER or TEXT_ALIGN_RIGHT. |
setSharpness(s: float) | void | Go writes TextBlock.Sharpness; here it drives willow's Text.sharpness (item 7136). |
setWrapWidth(w: float) | void | Maximum line width for wrapping; zero means no wrapping. |
bindText(ref: Ref<string>) | void | Follow 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)| Method | Returns | Notes |
|---|---|---|
setText(t: string) | void | |
bindText(ref: Ref<string>) | void | The label follows the ref; any previous binding is stopped first. |
setOnClick(fn: Function | null) | void | |
setSize(w: float, h: float) | void | Sets 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)| Method | Returns | Notes |
|---|---|---|
setIconKey(key: string) | void | The icon from a sprite key in the effective theme's sprites map; an unknown key clears the icon. |
setIconImage(img: any) | void | The 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) | void | Override 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) | void | The toggle-style active highlight. A bound ref follows the value. |
bindActive(ref: Ref<boolean>) | void | Follow 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)| Method | Returns | Notes |
|---|---|---|
setRegion(region: TextureRegion | null) | void | An atlas sprite; clears any Texture. |
setImage(tex: Texture | null) | void | A raw Texture; clears any region. null clears the image. |
clearImage() | void | Leave the widget empty. |
setScaleMode(mode: int) | void | |
setTint(c: Color) | void | |
setAlpha(a: float) | void | The 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() | void | Resize 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)| Method | Returns | Notes |
|---|---|---|
applyThemeColors() | void | Background, border and padding from the effective theme's TooltipGroup. |
setSize(w: float, h: float) | void | Explicit dimensions, bypassing auto-size. |
setText(text: string, family: string, size: float) | void | Replace 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) | void | Show at a screen position, bypassing the hover delay. Hide it with hide(). |
hide() | void | Hide 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.
| Method | Returns | Notes |
|---|---|---|
setScene(s: any) | void | Called on every setScene: hide what is showing and make sure the nodes exist. |
showAtPosition(tt: Tooltip, px: float, py: float) | void | Show 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) | void | Hide 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.
| Method | Returns | Notes |
|---|---|---|
applyThemeColors() | void | |
applyThumbState() | void | |
setScrollPos(v: float) | void | Clamp 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) | void | The 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<float>) | void | Follow 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)| Method | Returns | Notes |
|---|---|---|
addContent(child: Component | null) | void | Add 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) | void | A 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) | void | Add a child component; its node goes inside the scrollable content container. |
removeChild(child: Component | null) | void | Detach a child from the content container (the node that holds it, not the panel node). |
Screen
Source: src/core/controller.tks.
| Method | Returns | Notes |
|---|---|---|
add(e: Component) | void | |
addNode(n: Node) | void | |
remove(e: Component) | void | |
removeNode(n: Node) | void | |
isVisible() | boolean | |
show() | void | Attach the root node to the scene and call onCreate on first show. |
hide() | void | Detach the root node but keep all state. |
clearTemplateTree() | void | Stop all tracked refs and remove every child of the root (hot reload). |
findByName(name: string) | Component | null | The component with this name in the tree, or null. |
StageManager
Source: src/core/controller.tks.
A stack of screens.
| Method | Returns | Notes |
|---|---|---|
setScene(s: Node | null) | void | Set the scene root used to attach screens; screens without one adopt it. |
add(screen: Screen) | void | Push and show. |
remove(screen: Screen) | void | Dispose and remove a specific screen. |
closeAll() | void | |
size() | int |