Skip to content

Modern Tui TuiFocusRing

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

Home › Terminal TUI Library › Widgets › TuiFocusRing

TuiFocusRing

Holds the Tab order of your widgets and tells each one when it has focus.

Syntax

type TuiFocusRing
    as int32 cur
    declare sub Add( byval w as TuiWidget ptr )
    declare sub Next_( )
    ...
end type

Description

Tab order, as a ring. It calls SetFocused for you and never owns or frees anything. THE RING HOLDS POINTERS, so everything you Add must outlive the frame -- widgets built as locals inside View die at END SUB, and a form whose inputs were locals could not be Tabbed to at all. Make focusable widgets fields of your app.

Example

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

type FormApp extends TuiApp
    as TuiTextInput  nameBox      '' FIELDS, not locals
    as TuiCheckbox   agree
    as TuiFocusRing  ring
    as TuiTextInputState nameState
    as boolean agreed
    declare function Init( ) as TuiCmd override
    declare function Update( byref e as TuiEvent ) as TuiCmd override
    declare sub View( byref f as TuiFrame ) override
end type

function FormApp.Init( ) as TuiCmd
    TuiTextInputStateInit( nameState )
    nameBox.state = @nameState
    agree.checked = @agreed

    ring.Add( @nameBox )          '' both outlive every frame
    ring.Add( @agree )
    return TuiNone( )
end function

See also

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

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