Skip to content

Text 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.

ColorPicker ​

Source: src/widgets/text/colorpicker.tks. Extends Component.

ts
new ColorPicker(name: string, family: string, displaySize: float)

Callback fields: onChange, onCommit.

MethodReturnsNotes
setShowAlpha(show: boolean)voidWhether the alpha channel is editable in the popup.
setDefaultMode(mode: int)voidThe mode shown first when the popup opens.
setValue(c: Color)voidSet the colour without opening the popup.
bindValue(ref: Ref<Color>)voidThe picker writes back to the ref; external writes update the picker.
setOnChange(fn: Function | null)voidInvoked whenever the colour changes (each drag step).
setOnCommit(fn: Function | null)voidInvoked when the popup closes with a committed value.
open()void
close()void
cancel()void
setSize(w: float, h: float)void

ColorPickerPopup ​

Source: src/widgets/text/colorpicker.tks.

ts
new ColorPickerPopup(trigger: ColorPicker)
MethodReturnsNotes
setMode(mode: int)void

ColorPickerManager ​

Source: src/widgets/text/colorpicker.tks.

Manages the single active floating picker popup.

MethodReturnsNotes
show(trigger: ColorPicker)voidOpen the popup for a trigger, below it and clamped to the window.
commitAndClose()void
cancelAndClose()void
isOpen()boolean

InputField ​

Source: src/widgets/text/inputfield.tks. Extends Component.

ts
new InputField(name: string, family: string, displaySize: float)
MethodReturnsNotes
setLabel(text: string)void
setLabelPosition(pos: int)void
setRequired(v: boolean)void
setRequiredMarker(s: string)voidThe character(s) appended to the label when required (default "*").
setValidationState(state: int)void
setValidationMessage(msg: string)void
clearValidation()void
setValue(v: string)void
getValue()string
setPlaceholder(v: string)void
bindValue(ref: Ref<string>)void
setOnChange(fn: Function | null)void
setOnSubmit(fn: Function | null)void
setOnBlur(fn: Function | null)void
setMaxLength(n: int)void
setReadOnly(v: boolean)void
setEnabled(v: boolean)void
setSize(w: float, h: float)voidThe input width and height; the label and message size themselves.
setWidth(w: float)voidWidth only; the height comes from the font size.

MaskToken ​

Source: src/widgets/text/maskedinput.tks.

ts
new MaskToken(kind: int, literal: string)

MaskedInput ​

Source: src/widgets/text/maskedinput.tks. Extends Component.

ts
new MaskedInput(name: string, family: string, displaySize: float)

Callback fields: onChange, onRawChange, onSubmit, onBlur, onComplete, onIncomplete.

MethodReturnsNotes
setMask(mask: string)voidParse and apply a new mask, resetting every slot.
value()stringThe formatted display string (filled slots and literals).
setValue(v: string)voidFill slots from a formatted string; characters that fit a slot are taken, others skipped.
setRawValue(v: string)void
setPlaceholder(p: string)void
getPlaceholder()string
setMaskPlaceholder(ch: string)voidThe character shown for unfilled slots ("" = blank). Rebuilds the cells: widths derive from it.
setMaxLength(n: int)void
isComplete()boolean
isEmpty()boolean
clear()void
selectAll()void
hasSelection()boolean
selectedText()stringThe display text of the selected range, literals inside the range included.
clearSelection()void
setOnChange(fn: Function | null)void
setOnRawChange(fn: Function | null)void
setOnSubmit(fn: Function | null)void
setOnBlur(fn: Function | null)void
setOnComplete(fn: Function | null)void(raw: string, formatted: string) => void, when all slots become filled.
setOnIncomplete(fn: Function | null)void
bindValue(ref: Ref<string>)voidTwo-way: the ref follows every change, external changes refill the slots.
bindRawValue(ref: Ref<string>)void
setWidth(w: float)voidWidth only: the height comes from the font and the theme padding.
setSize(w: float, h: float)void
setEnabled(v: boolean)void
setCursorFromCell(localX: float, shift: boolean)voidA click on a filled slot puts the cursor there; on an empty slot or outside every slot it snaps to the first empty slot.
insertText(s: string)voidDistribute pasted characters into slots from the cursor; invalid ones are skipped.
moveCursorLeft()void
moveCursorLeftShift(shift: boolean)void
moveCursorRight()void
moveCursorRightShift(shift: boolean)void
moveCursorHomeShift(shift: boolean)void
moveCursorEndShift(shift: boolean)void
setDebugSlots(v: boolean)voidA debug overlay outlining each slot cell.
resetBlink()void
getCursorPos()int
setCursorPos(pos: int)void
getSelStart()int
getSelEnd()int

NumberStepper ​

Source: src/widgets/text/numberstepper.tks. Extends Component.

ts
new NumberStepper(name: string, family: string, displaySize: float)

Callback fields: onChange.

MethodReturnsNotes
setValue(v: float)voidClamp to [min, max], update the text, fire onChange and the bound ref.
setMin(v: float)void
setMax(v: float)void
setStep(v: float)void
setPageStep(v: float)void
setDecimals(n: int)voidDecimal places shown and accepted; negative is 0. Reformats the current value.
setOnChange(fn: Function | null)void
bindValue(ref: Ref&lt;float&gt;)voidTwo-way sync with a Ref<float>: external writes set the value, stepper changes write the ref.
setSize(w: float, h: float)voidThe step buttons are square (height x height); the text field fills the rest.
setEnabled(v: boolean)void

Source: src/widgets/text/searchbox.tks. Extends Component.

ts
new SearchBox(name: string, family: string, displaySize: float)

Callback fields: onChange, onSubmit, onBlur, onClear, onSearchStart, onSearchFinish, onSearchEmpty.

MethodReturnsNotes
value()string
setValue(v: string)void
bindValue(ref: Ref&lt;string&gt;)void
setPlaceholder(v: string)void
setSize(w: float, h: float)void
setWidth(w: float)voidWidth only; the height comes from the font and padding.
setShowSearchIcon(v: boolean)void
setShowClearButton(v: boolean)void
clear()voidEmpties the query, hides the clear button, clears results and fires onClear.
setOnChange(fn: Function | null)void
setOnSubmit(fn: Function | null)void
setOnClear(fn: Function | null)void
setOnBlur(fn: Function | null)void
setDebounce(ms: float)voidMilliseconds; 0 searches on every change.
cancelPendingSearch()void
setMinQueryLength(n: int)void
setSearchOnChange(v: boolean)void
setSearchOnSubmit(v: boolean)void
setOnSearchStart(fn: Function | null)void
setOnSearchFinish(fn: Function | null)void
setOnSearchEmpty(fn: Function | null)void
isSearching()boolean
setSearchRunner(fn: Function | null)void
hasSelection()boolean
selectAll()void
insertText(s: string)void
setEnabled(v: boolean)void
getPlaceholder()string
getCursorPos()int
clearVisible()boolean

Tag ​

Source: src/widgets/text/tag.tks. Extends Component.

ts
new Tag(name: string, family: string, displaySize: float)

Callback fields: onRemove, onToggle.

MethodReturnsNotes
setText(text: string)void
setRemovable(v: boolean)voidShow or hide the x affordance.
setSelectable(v: boolean)voidToggle-on-click behaviour.
setSelected(v: boolean)void
setOnRemove(fn: Function | null)void
setOnToggle(fn: Function | null)void
setPadding(top: float, right: float, bottom: float, left: float)voidPer-instance padding overriding the theme's.
setSize(w: float, h: float)void
sizeToContent()voidSize to the text plus padding (plus the x and its gap when removable), at least a circle.

TagBar ​

Source: src/widgets/text/tagbar.tks. Extends Component.

ts
new TagBar(name: string, family: string, displaySize: float)

Callback fields: onChange, onAddTag, onRemoveTag.

MethodReturnsNotes
setTags(tags: string[])voidReplace the whole list.
addTag(text: string)void
removeTagAt(idx: int)voidOut-of-range indices are ignored.
setOnChange(fn: Function | null)void
setOnAddTag(fn: Function | null)void
setOnRemoveTag(fn: Function | null)void
setPlaceholder(text: string)void
setSize(w: float, h: float)void

VisualLine ​

Source: src/widgets/text/textarea.tks.

One visual line: a rune range of the value, from a hard break or a word wrap (Go visualLine).

ts
new VisualLine(runeStart: int, runeEnd: int)

LineCol ​

Source: src/widgets/text/textarea.tks.

ts
new LineCol(line: int, col: int)

TextArea ​

Source: src/widgets/text/textarea.tks. Extends Component.

ts
new TextArea(name: string, family: string, displaySize: float)

Callback fields: onChange.

MethodReturnsNotes
hasSelection()boolean
selectedText()string
selectAll()void
clearSelection()void
setValue(v: string)void
setRows(n: int)voidVisible rows; the height follows (at least one).
setMaxLength(n: int)void
setCharFilter(fn: Function | null)voidNewlines are always accepted regardless of the filter.
setNumericOnly()void
setAlphanumericOnly()void
setAllowedChars(chars: string)void
setOnChange(fn: Function | null)void
setSize(w: float, h: float)void
bindValue(ref: Ref&lt;string&gt;)voidFollow a Ref<string> (the widget's own writes are not echoed back).
insertText(text: string)void
setEnabled(v: boolean)void
moveCursorLeft()void
moveCursorLeftShift(shift: boolean)void
moveCursorRight()void
moveCursorRightShift(shift: boolean)void
moveCursorWordLeftShift(shift: boolean)void
moveCursorWordRightShift(shift: boolean)void
moveCursorUp()voidThe same x on the previous visual line (the start of the text on the first line).
moveCursorUpShift(shift: boolean)void
moveCursorDown()voidThe same x on the next visual line (the end of the text on the last line).
moveCursorDownShift(shift: boolean)void
moveCursorHomeShift(shift: boolean)void
moveCursorEndShift(shift: boolean)void
moveCursorPageUpShift(shift: boolean)void
moveCursorPageDownShift(shift: boolean)void
selectWordAtCursor()void
getVisualLines()VisualLine[]The value split into visual lines: hard breaks (newline) and word wraps at the wrap width.
setCursorFromClick(localX: float, localY: float, shift: boolean)voidPlace the cursor at the character closest to local (x, y); shift extends from the anchor.
resetBlink()void
setComposition(text: string, selectionStart: int = 0, selectionLength: int = 0, replacementStart: int = -1, replacementLength: int = 0)voidPublic for deterministic visual tests and host adapters. This never edits value.

WordRange ​

Source: src/widgets/text/textinput.tks.

ts
new WordRange(lo: int, hi: int)

TextInput ​

Source: src/widgets/text/textinput.tks. Extends Component.

ts
new TextInput(name: string, family: string, displaySize: float)

Callback fields: onChange, onSubmit, onBlur.

MethodReturnsNotes
hasSelection()boolean
selectedText()string
selectAll()void
clearSelection()voidCollapse the selection to the cursor.
setValue(v: string)void
setPlaceholder(p: string)void
setMaxLength(n: int)voidCharacter limit (0 = none).
setCharFilter(fn: Function | null)voidCalled for each typed or pasted character (one code point string): true accepts it. null clears.
setNumericOnly()void
setAlphanumericOnly()void
setAllowedChars(chars: string)void
setOnChange(fn: Function | null)void
setOnSubmit(fn: Function | null)void
setOnBlur(fn: Function | null)void
setKeyFilter(fn: Function | null)voidCalled before special-key handling; true skips the default handling of that key (Home, End).
bindValue(ref: Ref&lt;string&gt;)voidFollow a Ref<string>: takes its value now and at every later external change.
insertText(text: string)voidInsert at the cursor, replacing any selection. Newlines are stripped (single line).
moveCursorLeft()void
moveCursorLeftShift(shift: boolean)void
moveCursorRight()void
moveCursorRightShift(shift: boolean)void
moveCursorWordLeftShift(shift: boolean)void
moveCursorWordRightShift(shift: boolean)void
moveCursorHomeShift(shift: boolean)void
moveCursorEndShift(shift: boolean)void
selectWordAtCursor()voidSelect the word under the cursor.
setPasswordMode(v: boolean)void
isPasswordMode()boolean
bindPasswordMode(ref: Ref&lt;boolean&gt;)void
setWidth(w: float)voidWidth only: the height comes from the font and theme padding.
setSize(w: float, h: float)void
setEnabled(v: boolean)void
setCursorFromX(localX: float, shift: boolean)voidPlace the cursor at the character closest to localX; shift extends from the anchor.
resetBlink()voidShow the cursor immediately after a change and restart the blink timer.
applyBorderColor(c: Color)voidBorder colour override without touching other visuals (InputField validation state).
setComposition(text: string, selectionStart: int = 0, selectionLength: int = 0, replacementStart: int = -1, replacementLength: int = 0)voidPublic for deterministic visual tests and host adapters. This never edits value.
getPlaceholder()stringTest-facing views (Go GetPlaceholder, SelRectVisible ...).