tui button for viewers
Add a button that runs a hook, or submits its label, when activated.
Command Type
built-in
Signature
> tui button {flags} (label) (hook)
Flags
--id {string}: Widget id.--focus: Start with this widget focused.
Parameters
label: Button text.hook: Closure run with the state record when activated.
Input/output types:
| input | output |
|---|---|
| nothing | tui |
| tui | tui |
| any | tui |
Examples
A yes/no confirm
> tui label "Delete everything?" | tui button Yes | tui button No | tui debug --keys [tab enter] | get selectedA button that saves the text box and quits
> tui textbox --id name | tui button Save {|s| $s.values.name | save name.txt; {action: quit} } | tui runNotes
Tab to the button and press Enter or Space, or click it. With a hook closure the button behaves like tui bind: the closure receives the state record and may return a new data list or {action: submit|quit, ...}. Without one, activating submits the label, so tui button Yes | tui button No is a confirm dialog.