Interactive 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.
- CalendarDayCell
- CalendarSelector
- Checkbox
- ContextMenu
- DragHandle
- ImageCropper
- KeybindInput
- MenuBarEntry
- MenuBarNode
- MenuBar
- MenuItem
- MenuPopup
- MenuPopupManager
- OptionRotator
- Popover
- PopoverManager
- RadioButton
- Radio
- SelectOption
- Select
- Slider
- TimeValue
- TimeColumn
- TimePicker
- Toggle
- ToggleButtonBar
- ToolBar
- ToolGroup
CalendarDayCell
Source: src/widgets/interactive/calendarselector.tks.
A single day cell in the grid.
ts
new CalendarDayCell(container: Node, bg: Quad, label: Text)CalendarSelector
Source: src/widgets/interactive/calendarselector.tks. Extends Component.
ts
new CalendarSelector(name: string, family: string, displaySize: float)Callback fields: onDateSelected.
| Method | Returns | Notes |
|---|---|---|
setDate(t: Date) | void | The selected date, and navigate to its month. Does not fire onDateSelected. |
setMinDate(t: Date) | void | |
setMaxDate(t: Date) | void | |
clearMinDate() | void | |
clearMaxDate() | void | |
setPopupMode(v: boolean) | void | Switch between inline and popup display. |
isPopupMode() | boolean | |
openPopup() | void | Open the popup calendar (popup mode only). |
closePopup() | void | Close the popup calendar (popup mode only). |
setMonth(year: int, month: int) | void | Navigate the view to a year and month (1-12). |
setOnDateSelected(fn: Function | null) | void | |
bindDate(ref: Ref<Date>) | void | The selected date follows the ref and user picks write to it. |
setSize(w: float, h: float) | void | |
setEnabled(v: boolean) | void | |
isDateDisabled(t: Date) | boolean |
Checkbox
Source: src/widgets/interactive/checkbox.tks. Extends Component.
ts
new Checkbox(name: string, text: string, family: string, displaySize: float)Callback fields: onChange.
| Method | Returns | Notes |
|---|---|---|
setChecked(v: boolean) | void | |
setText(text: string) | void | |
bindValue(ref: Ref<boolean>) | void | The checkbox follows the ref (initial value applied now), and clicks write to it. |
setCheckIcon(img: TextureRegion) | void | Replace the built-in check glyph with a custom image, shown at the box size. |
setEnabled(v: boolean) | void |
ContextMenu
Source: src/widgets/interactive/contextmenu.tks.
ts
new ContextMenu(family: string, displaySize: float)| Method | Returns | Notes |
|---|---|---|
setItems(items: MenuItem[]) | void | Replace the item list. |
setVariant(v: int) | void | |
showAt(x: float, y: float) | void | Open the menu with its top-left at (x, y) in world/screen coordinates. |
hide() | void | Close the menu if it is open. |
DragHandle
Source: src/widgets/interactive/draghandle.tks. Extends Component.
ts
new DragHandle(name: string)Callback fields: onDragStart, onDrag, onDragEnd.
| Method | Returns | Notes |
|---|---|---|
setAxis(a: int) | void | |
setTarget(c: Component | null) | void | |
clearTarget() | void | |
setGripStyle(s: int) | void | |
setSize(w: float, h: float) | void | |
setEnabled(v: boolean) | void |
ImageCropper
Source: src/widgets/interactive/imagecropper.tks. Extends Component.
ts
new ImageCropper(name: string)Callback fields: onCropChanged.
| Method | Returns | Notes |
|---|---|---|
setImage(img: Texture | null) | void | Set the source image (null clears it). The crop defaults to the whole image the first time. |
setCropRect(x: float, y: float, w: float, h: float) | void | The crop rectangle in image-pixel coordinates. |
setAspectRatio(w: float, h: float) | void | Constrain the crop to a fixed aspect ratio; 0, 0 is free. |
setMinSize(w: float, h: float) | void | |
setMaxSize(w: float, h: float) | void | |
setShowGrid(v: boolean) | void | The rule-of-thirds grid overlay. |
setOnCropChanged(fn: Function | null) | void | Fired during handle drags with the new crop rectangle. |
setSize(w: float, h: float) | void | |
startDrag(handleIdx: int, gx: float, gy: float) | void | Begin a drag of a handle (or -1 to move the whole rect) at the global pointer position. |
KeybindInput
Source: src/widgets/interactive/keybindinput.tks. Extends Component.
ts
new KeybindInput(name: string, family: string, displaySize: float)Callback fields: onBindingChanged, onConflict.
| Method | Returns | Notes |
|---|---|---|
getBinding() | KeyBinding | |
setBinding(b: KeyBinding) | void | Set the binding without entering listening mode or firing the callback. |
clearBinding() | void | |
setListening(v: boolean) | void | |
isListening() | boolean | |
setCombosEnabled(v: boolean) | void | |
setOnBindingChanged(fn: Function | null) | void | |
setOnConflict(fn: Function | null) | void | Return false from the callback to reject a binding. |
bindValue(ref: Ref<KeyBinding>) | void | The binding follows the ref and user captures write to it. |
setSize(w: float, h: float) | void | |
setEnabled(v: boolean) | void |
MenuBarEntry
Source: src/widgets/interactive/menubar.tks.
One top-level menu in the bar.
ts
new MenuBarEntry(label: string, items: MenuItem[])MenuBarNode
Source: src/widgets/interactive/menubar.tks.
Per-entry visual data.
ts
new MenuBarNode(bg: Quad, label: Text, hit: Node, x: float, w: float)MenuBar
Source: src/widgets/interactive/menubar.tks. Extends Component.
ts
new MenuBar(name: string, family: string, displaySize: float)Callback fields: onMenuOpen, onMenuClose.
| Method | Returns | Notes |
|---|---|---|
setEntries(entries: MenuBarEntry[]) | void | |
setEntry(index: int, entry: MenuBarEntry) | void | Replace one entry; out of range is ignored. |
setSize(w: float, h: float) | void | |
setOnMenuOpen(fn: Function | null) | void | |
setOnMenuClose(fn: Function | null) | void | |
applyTheme() | void | |
rebuild() | void | |
hideOverlay() | void | Remove the overlay and restore the normal entry node references. |
openMenu(index: int) | void | |
closeMenu() | void | Close the open dropdown; the popup's onDismiss does the state cleanup. |
MenuItem
Source: src/widgets/interactive/menupopup.tks.
A single entry in a MenuPopup.
ts
new MenuItem(label: string, onSelect: Function | null)Callback fields: onSelect.
MenuPopup
Source: src/widgets/interactive/menupopup.tks.
ts
new MenuPopup(family: string, displaySize: float)Callback fields: onDismiss.
| Method | Returns | Notes |
|---|---|---|
setItems(items: MenuItem[]) | void | |
setOnDismiss(fn: Function | null) | void | |
setVariant(v: int) | void | |
scrollToHighlighted() | void | Keep the highlighted item in view when navigating by keyboard in a scrollable popup. |
MenuPopupManager
Source: src/widgets/interactive/menupopup.tks.
Manages the single active floating menu popup. Use DEFAULT_MENU_POPUP_MANAGER.
| Method | Returns | Notes |
|---|---|---|
setScene(s: any) | void | |
show(popup: MenuPopup, trigger: Component | null) | void | Display popup below (or above) the trigger component. |
showAt(popup: MenuPopup, x: float, y: float) | void | Display popup with its top-left at (x, y). |
hide() | void | Close the active popup without a selection. |
isOpen() | boolean | |
dismiss() | void | |
hideActive() | void | |
setHighlight(idx: int) | void | Item pointer enter. |
clearHighlight(idx: int) | void | Item pointer leave. |
selectItem(idx: int) | void | Fire the item's onSelect and close the popup. |
OptionRotator
Source: src/widgets/interactive/optionrotator.tks. Extends Component.
ts
new OptionRotator(name: string, options: string[], family: string, displaySize: float)Callback fields: onChange.
| Method | Returns | Notes |
|---|---|---|
setOptions(opts: string[]) | void | Replaces the list; the index is clamped and onChange fires when that moves it. |
setSelected(i: int) | void | The index is clamped; onChange fires only when the selection changes. |
setWrap(v: boolean) | void | |
setChevronIcons(left: TextureRegion | null, right: TextureRegion | null) | void | Either icon may be null to keep the theme or built-in chevron for that side. |
bindOptions(arr: ReactiveArray<string> | null) | void | The options follow a ReactiveArray; the selection is clamped. Pass null to detach. |
bindSelected(ref: Ref<int>) | void | The index follows the ref and user changes write to it. Replaces any previous binding. |
bindValue(ref: Ref<string>) | void | The value string follows the ref; an unknown value resolves to index 0 (as in Go). |
value() | string | |
setSize(w: float, h: float) | void | |
setEnabled(v: boolean) | void |
Popover
Source: src/widgets/interactive/popover.tks. Extends Component.
ts
new Popover(name: string)Callback fields: onOpenCb, onCloseCb.
| Method | Returns | Notes |
|---|---|---|
setPreferredSide(side: int) | void | |
setContentSize(w: float, h: float) | void | The size of the content area (excluding the title bar). |
setTitle(text: string, family: string, size: float) | void | An optional title in the header; family is a registered font family. |
setShowCloseButton(v: boolean) | void | |
setContent(comp: Component | null) | void | |
setOnOpen(fn: Function | null) | void | |
setOnClose(fn: Function | null) | void | |
open(trigger: Component | null) | void | Open anchored to trigger, through DEFAULT_POPOVER_MANAGER; another open popover closes first. |
close() | void | |
isOpen() | boolean | |
setManager(m: any) | void | Remember which manager opened it (PopoverManager.open). |
PopoverManager
Source: src/widgets/interactive/popover.tks.
Manages the single active floating popover. Use DEFAULT_POPOVER_MANAGER.
| Method | Returns | Notes |
|---|---|---|
setScene(s: any) | void | Called on every setScene. |
open(p: Popover, trigger: Component | null) | void | Display p anchored to trigger (null centres it); an open popover closes first. |
close(p: Popover) | void | Close p if it is the active one. |
dismiss() | void | The dismiss node was clicked. |
hideActive(fireCallback: boolean) | void | Remove the active popover's node tree from the overlay. |
RadioButton
Source: src/widgets/interactive/radio.tks. Extends Component.
One option within a Radio.
ts
new RadioButton(group: RadioHost, groupName: string, index: int, text: string, family: string, displaySize: float)| Method | Returns | Notes |
|---|---|---|
setSelected(sel: boolean) | void | |
applyThemeColors() | void |
Radio
Source: src/widgets/interactive/radio.tks. Extends Component.
ts
new Radio(name: string)Callback fields: onChange.
| Method | Returns | Notes |
|---|---|---|
setColumns(n: int) | void | Columns (default 1 = one vertical stack); triggers a layout update. |
setVerticalFirst(v: boolean) | void | Fill order when columns > 1: false fills left to right then wraps, true fills each column top down. |
addOption(text: string, family: string, displaySize: float) | RadioButton | |
setSelected(idx: int) | void | Programmatic selection; does not fire onChange. |
bindSelected(ref: Ref<int>) | void | The group follows the ref (initial value applied now); clicks write to it. |
selectIndex(idx: int) | void |
SelectOption
Source: src/widgets/interactive/select.tks.
A single choice in a Select.
ts
new SelectOption(label: string, value: any)Select
Source: src/widgets/interactive/select.tks. Extends Component.
ts
new Select(name: string, options: SelectOption[], family: string, displaySize: float)Callback fields: onChange.
| Method | Returns | Notes |
|---|---|---|
setOptions(options: SelectOption[]) | void | Replace the options; the selection resets to 0. |
bindOptions(arr: ReactiveArray<SelectOption> | null) | void | The options follow a ReactiveArray; the selection is clamped. Pass null to detach. |
bindSelected(ref: Ref<int>) | void | The selection follows the ref and user choices write to it. Replaces any previous binding. |
setSelected(idx: int) | void | Select the option at idx; out of range is ignored. |
selectedOption() | SelectOption | |
setOnChange(fn: Function | null) | void | |
setSize(w: float, h: float) | void | The explicit size of the trigger button. |
setEnabled(v: boolean) | void |
Slider
Source: src/widgets/interactive/slider.tks. Extends Component.
ts
new Slider(name: string)Callback fields: onChange.
| Method | Returns | Notes |
|---|---|---|
setValue(v: float) | void | |
setRange(mn: float, mx: float) | void | |
setStep(s: float) | void | |
setOrientation(o: int) | void | |
setSize(w: float, h: float) | void | |
bindValue(ref: Ref<float>) | void | Follow the ref (initial value applied now); later writes one frame after. |
setEnabled(v: boolean) | void |
TimeValue
Source: src/widgets/interactive/timepicker.tks.
A time of day: hour (0-23), minute and second.
ts
new TimeValue(hour: int, minute: int, second: int)TimeColumn
Source: src/widgets/interactive/timepicker.tks.
An up/down stepper column for one time field.
ts
new TimeColumn(container: Node, upBtn: Button, downBtn: Button, label: Quad, labelText: Text)| Method | Returns | Notes |
|---|---|---|
setEnabled(v: boolean) | void |
TimePicker
Source: src/widgets/interactive/timepicker.tks. Extends Component.
ts
new TimePicker(name: string, family: string, displaySize: float)Callback fields: onTimeChanged.
| Method | Returns | Notes |
|---|---|---|
setTime(h: int, m: int, s: int) | void | Set the time; h is in the 24h range. |
setShowSeconds(v: boolean) | void | |
setFormat(format: int) | void | |
setOnTimeChanged(fn: Function | null) | void | Callback (hour24, minute, second) fired when any field changes by user interaction. |
bindTime(ref: Ref<TimeValue>) | void | The time follows the ref and user steps write to it. |
setSize(w: float, h: float) | void | |
setEnabled(v: boolean) | void | |
setDisplayHour(dispH: int) | void | Convert a 12h display hour back to 24h and store it. |
toggleAmPm() | void |
Toggle
Source: src/widgets/interactive/toggle.tks. Extends Component.
ts
new Toggle(name: string)Callback fields: onChange.
| Method | Returns | Notes |
|---|---|---|
setValue(v: boolean) | void | |
bindValue(ref: Ref<boolean>) | void | Follow the ref (initial value applied now); clicks write to it. |
setEnabled(v: boolean) | void |
ToggleButtonBar
Source: src/widgets/interactive/togglebuttonbar.tks. Extends Component.
ts
new ToggleButtonBar(name: string, family: string, displaySize: float)Callback fields: onChange.
| Method | Returns | Notes |
|---|---|---|
addButton(label: string) | void | |
removeButton(idx: int) | void | |
setSelected(idx: int) | void | Out-of-range indices are ignored; onChange fires only when the index changes. |
bindButtons(arr: ReactiveArray<string> | null) | void | The button labels follow a ReactiveArray: the bar is rebuilt on each change, keeping the selection index where possible. Pass null to detach. |
bindSelected(ref: Ref<int>) | void | The bar follows the ref (initial value applied now); selections write to it. |
setSize(w: float, h: float) | void |
ToolBar
Source: src/widgets/interactive/toolbar.tks. Extends Component.
ts
new ToolBar(name: string)| Method | Returns | Notes |
|---|---|---|
setOrientation(o: int) | void | |
addItem(comp: Component) | void | |
addSeparator() | void | |
addSpacer() | void | |
removeItem(nm: string) | void | Removes the component item with this name (separators and spacers are not matched). |
clear() | void | |
setOverflowMode(mode: int) | void | |
setWrap(v: boolean) | void | |
setSize(w: float, h: float) | void |
ToolGroup
Source: src/widgets/interactive/toolgroup.tks.
Callback fields: onChange.
| Method | Returns | Notes |
|---|---|---|
setAllowNone(v: boolean) | void | |
add(btn: IconButton) | void | |
setSelected(idx: int) | void | |
bindSelected(ref: Ref<int>) | void | The group follows the ref (initial value applied now); selections write to it. |