-
Notifications
You must be signed in to change notification settings - Fork 0
TabTrinket
Wire names tabs · tab
A strip of tabs over a stack of pages. One page is visible at a time and the strip chooses which.
t=new tabs children={
new tab caption="General" children={ new panel layout=vbox children={ … } }
new tab caption="Advanced" children={ new panel layout=vbox children={ … } }
}
| Property | Type | Default | Meaning |
|---|---|---|---|
background |
color | — | Tab body background color. |
closable |
flag | false |
Show per-tab close buttons. |
movable |
flag | false |
Allow reordering tabs by drag. |
position |
top | bottom | left | right
|
— | Tab strip edge. |
selected |
int | 0 |
Active tab index. |
Plus the common properties.
| Property | Type | Default | Meaning |
|---|---|---|---|
caption |
string | — | Tab label text. |
tab is a virtual type — a page of the strip rather than a trinket placed on
its own — so it takes no common properties and has no identity of its own.
change — A different tab was selected.
| Field | Type | Meaning |
|---|---|---|
trinket |
uint | The tab strip's object ID. |
selected |
int | Index of the newly selected tab. |
change is the strip's, not the page's. Which page became visible is the
index; reach the page itself by surfacing a key inside it.
A tab holds exactly one child, the same rule a Window follows.
Two is an error rather than a silent drop:
new tab caption="A" children={ new label caption="a"; new label caption="b" }
-> tab: only one content trinket (wrap several in a panel)
So in practice almost every tab's child is a Panel:
new tab caption="General" children={
new panel layout=vbox spacing=8 children={
new label caption="Name:"
new textinput
}
}
The same ordering trap as ListView, and just as silent:
new tabs selected=2 children={new tab caption="A" children={new label caption="a"}; new tab caption="B" children={new label caption="b"}; new tab caption="C" children={new label caption="c"}}
-> selected = 0
new tabs children={new tab caption="A" children={new label caption="a"}; new tab caption="B" children={new label caption="b"}; new tab caption="C" children={new label caption="c"}} selected=2
-> selected = 2
Note the default here is 0, not -1 — a tab strip always has a current
tab once it has any tabs at all. A template carrying
the tabs settles the ordering for good.
movable lets the user drag tabs into a different order. closable puts a
close control on each tab.
Both change what the user can do to the strip, and neither raises an event of its own — a close is a structural change, so an application that needs to know a page went away should watch the page rather than the strip.
background paints the tab body and is the color the strip reports to its
children, so a page inherits it. The common bg is a style override on the
strip itself.
The word default clears background back to inherited.
| Does | |
|---|---|
Left Right
|
Move to the previous / next tab. |
| Click a tab | Select it. |
| Drag a tab | Reorder, with movable. |
The strip takes focus by Tab only — it is TabFocus, not click-focus, so
clicking a tab selects the page without stealing the keyboard from whatever
is inside it.
Panel — what nearly every tab contains · ListView — the other index-selected trinket · Window · Common Properties
KittyTK — image/tty Trinket Kit · MIT licensed · alpha, 0.1.x
Repository · Issues · Support on ko-fi
Sibling projects: PurfecTerm (terminal emulator) · mew (text editor) · PawScript (language)
Getting Started
Installation Building from Source Running a Display Host Your First Application Examples
Protocol
Protocol Overview Object Model Properties and Values Events Templates and Aliases Common Properties Introspection Transports and Security
Clients
Go Client Python Client C Client
Application Objects
Application · MenuBar · Window · MessageBox
Output Trinkets
Label · ProgressBar · StatusBar
Input Trinkets
TextInput · Editor · Terminal
Button · CheckBox · RadioButton
ListView · ComboBox · TreeView
Layout Trinkets
TabTrinket · Panel
ScrollArea · MDIPane
Separator · Spacer · Splitter
Other Trinkets
Layout Helpers