Skip to content

Modern Tui TuiButton

Paul Squires edited this page Oct 19, 2026 · 6 revisions

Home › Terminal TUI Library › Widgets › TuiButton

TuiButton

Draws a button that calls your procedure when the user presses Enter on it.

Syntax

type TuiButton extends TuiWidget
    as ustring label
    as int32 id
    as TuiOnClick onclick
    as TuiStyle normal, active
end type

Description

A focusable button whose callback is a PLAIN procedure pointer. For a callback that captures something, use TuiButtonOf -- a capturing lambda cannot be converted to a procptr at all, which is error 355.

Example

#import "std/numeric"
#import "std/tui"
using tui, numeric

sub OnSave( byval id as int32 )
    print "saved, button id "; id
end sub

dim as TuiButton b
b.label = "Save"
b.id = 1
b.onclick = @OnSave
b.SetFocused( TRUE )

dim as TuiEvent e
e.kind = TUIEVENT_KEY : e.key.code = TUIKEY_ENTER
print b.HandleEvent( e )          '' true, and OnSave ran

See also

TuiWidget TuiWidget.HandleEvent TuiWidget.SetFocused TuiFocusRing.Clear
TuiWidget.Render TuiWidget.SizeHint TuiFocusRing TuiFocusRing.Count
TuiWidget.Kind TuiWidget.CanFocus TuiFocusRing.Add TuiFocusRing.Current

Library: Terminal TUI Library
Category: Terminal TUI Library
Documented under: Widgets
Working examples: hello.tiko · form.tiko · dashboard.tiko


Home · Keyword Index

Clone this wiki locally