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
- ColorPickerPopup
- ColorPickerManager
- InputField
- MaskToken
- MaskedInput
- NumberStepper
- SearchBox
- Tag
- TagBar
- VisualLine
- LineCol
- TextArea
- WordRange
- TextInput
ColorPicker
Source: src/widgets/text/colorpicker.tks. Extends Component.
ts
new ColorPicker(name: string, family: string, displaySize: float)Callback fields: onChange, onCommit.
| Method | Returns | Notes |
|---|---|---|
setShowAlpha(show: boolean) | void | Whether the alpha channel is editable in the popup. |
setDefaultMode(mode: int) | void | The mode shown first when the popup opens. |
setValue(c: Color) | void | Set the colour without opening the popup. |
bindValue(ref: Ref<Color>) | void | The picker writes back to the ref; external writes update the picker. |
setOnChange(fn: Function | null) | void | Invoked whenever the colour changes (each drag step). |
setOnCommit(fn: Function | null) | void | Invoked 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)| Method | Returns | Notes |
|---|---|---|
setMode(mode: int) | void |
ColorPickerManager
Source: src/widgets/text/colorpicker.tks.
Manages the single active floating picker popup.
| Method | Returns | Notes |
|---|---|---|
show(trigger: ColorPicker) | void | Open 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)| Method | Returns | Notes |
|---|---|---|
setLabel(text: string) | void | |
setLabelPosition(pos: int) | void | |
setRequired(v: boolean) | void | |
setRequiredMarker(s: string) | void | The 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) | void | The input width and height; the label and message size themselves. |
setWidth(w: float) | void | Width 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.
| Method | Returns | Notes |
|---|---|---|
setMask(mask: string) | void | Parse and apply a new mask, resetting every slot. |
value() | string | The formatted display string (filled slots and literals). |
setValue(v: string) | void | Fill 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) | void | The 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() | string | The 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>) | void | Two-way: the ref follows every change, external changes refill the slots. |
bindRawValue(ref: Ref<string>) | void | |
setWidth(w: float) | void | Width 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) | void | A 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) | void | Distribute 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) | void | A 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.
| Method | Returns | Notes |
|---|---|---|
setValue(v: float) | void | Clamp 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) | void | Decimal places shown and accepted; negative is 0. Reformats the current value. |
setOnChange(fn: Function | null) | void | |
bindValue(ref: Ref<float>) | void | Two-way sync with a Ref<float>: external writes set the value, stepper changes write the ref. |
setSize(w: float, h: float) | void | The step buttons are square (height x height); the text field fills the rest. |
setEnabled(v: boolean) | void |
SearchBox
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.
| Method | Returns | Notes |
|---|---|---|
value() | string | |
setValue(v: string) | void | |
bindValue(ref: Ref<string>) | void | |
setPlaceholder(v: string) | void | |
setSize(w: float, h: float) | void | |
setWidth(w: float) | void | Width only; the height comes from the font and padding. |
setShowSearchIcon(v: boolean) | void | |
setShowClearButton(v: boolean) | void | |
clear() | void | Empties 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) | void | Milliseconds; 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.
| Method | Returns | Notes |
|---|---|---|
setText(text: string) | void | |
setRemovable(v: boolean) | void | Show or hide the x affordance. |
setSelectable(v: boolean) | void | Toggle-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) | void | Per-instance padding overriding the theme's. |
setSize(w: float, h: float) | void | |
sizeToContent() | void | Size 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.
| Method | Returns | Notes |
|---|---|---|
setTags(tags: string[]) | void | Replace the whole list. |
addTag(text: string) | void | |
removeTagAt(idx: int) | void | Out-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.
| Method | Returns | Notes |
|---|---|---|
hasSelection() | boolean | |
selectedText() | string | |
selectAll() | void | |
clearSelection() | void | |
setValue(v: string) | void | |
setRows(n: int) | void | Visible rows; the height follows (at least one). |
setMaxLength(n: int) | void | |
setCharFilter(fn: Function | null) | void | Newlines 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<string>) | void | Follow 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() | void | The same x on the previous visual line (the start of the text on the first line). |
moveCursorUpShift(shift: boolean) | void | |
moveCursorDown() | void | The 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) | void | Place 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) | void | Public 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.
| Method | Returns | Notes |
|---|---|---|
hasSelection() | boolean | |
selectedText() | string | |
selectAll() | void | |
clearSelection() | void | Collapse the selection to the cursor. |
setValue(v: string) | void | |
setPlaceholder(p: string) | void | |
setMaxLength(n: int) | void | Character limit (0 = none). |
setCharFilter(fn: Function | null) | void | Called 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) | void | Called before special-key handling; true skips the default handling of that key (Home, End). |
bindValue(ref: Ref<string>) | void | Follow a Ref<string>: takes its value now and at every later external change. |
insertText(text: string) | void | Insert 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() | void | Select the word under the cursor. |
setPasswordMode(v: boolean) | void | |
isPasswordMode() | boolean | |
bindPasswordMode(ref: Ref<boolean>) | void | |
setWidth(w: float) | void | Width 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) | void | Place the cursor at the character closest to localX; shift extends from the anchor. |
resetBlink() | void | Show the cursor immediately after a change and restart the blink timer. |
applyBorderColor(c: Color) | void | Border colour override without touching other visuals (InputField validation state). |
setComposition(text: string, selectionStart: int = 0, selectionLength: int = 0, replacementStart: int = -1, replacementLength: int = 0) | void | Public for deterministic visual tests and host adapters. This never edits value. |
getPlaceholder() | string | Test-facing views (Go GetPlaceholder, SelRectVisible ...). |