-
Notifications
You must be signed in to change notification settings - Fork 0
ListView
Wire name listview
A single-column list of selectable rows.
l=new listview children={
new item caption="Alpha"
new item caption="Beta"
new item caption="Gamma"
} selected=0
| Property | Type | Default | Meaning |
|---|---|---|---|
alternate_rows |
flag | false |
Ledger-band non-selected rows. Same switch as ledger; prefer ledger. |
ledger |
flag | false |
Alternate non-selected rows in the ledger colors. |
selected |
int | -1 |
Selected row index (-1 = none). |
Plus the common properties.
Rows are children of the shared virtual item type, whose caption is the
row text. The same item builds a TreeView and a
ComboBox; nesting items is a tree's business, and a list rejects
it.
activate — A row was activated — double-clicked, or Enter on the selection.
| Field | Type | Meaning |
|---|---|---|
trinket |
uint | The list's object ID. |
selected |
int | Index of the activated row. |
change — The selection moved.
| Field | Type | Meaning |
|---|---|---|
trinket |
uint | The list's object ID. |
selected |
int | Index of the newly selected row, or -1 for none. |
change is the selection moving — by arrow key, by click, or by an
application set. activate is the user choosing a row: double-click, or
Enter on the selection. A list that opens something wants activate; a list
that drives a detail pane beside it wants change.
selected indexes rows that have to exist already, and properties apply in
the order they are written. Out of order it does not error — it quietly
lands somewhere else:
new listview selected=2 children={new item caption="A"; new item caption="B"; new item caption="C"}
-> selected = 0
new listview children={new item caption="A"; new item caption="B"; new item caption="C"} selected=2
-> selected = 2
Both build the same three rows. Only the second honours the index you asked for, and there is no error at build time — just the wrong row highlighted later.
Writing children first is enough in one statement. Where the same list is
built more than once, a template settles it for
good, because a template's children are applied before any instance's
properties:
template Sizes=listview children={
new item caption="Small"
new item caption="Medium"
new item caption="Large"
}
lv=new Sizes selected=2
The order is now the template's business rather than each caller's.
The same applies to ComboBox and TreeView.
-1 means nothing is selected, and an empty list reports -1. A client's
handle mirrors the value, so reading it is local:
l := ui.ListView("l")
l.Selected() // the replica's index
l.Select(2) // write through
l.OnChange(func(i int) { … })| Does | |
|---|---|
Up Down
|
Move the selection. |
Home End
|
First / last row. |
PageUp PageDown
|
A screenful. |
Return |
Activate the selection. |
| Click | Select. |
| Double-click | Activate. |
It takes focus by Tab and by click.
ledger and alternate_rows are the same switch. Either one bands the
non-selected rows in the scheme's ledger colors — the green-bar look — and
the selection keeps its own colors either way.
They are not two features that combine. They write the same state, so the last one written wins:
new listview ledger !alternate_rows children={new item caption="A"}
-> banding off
Prefer ledger. It is the name TreeView uses, and the only
one of the two that says what the banding looks like. alternate_rows is
kept so existing scripts keep working.
TreeView — nesting, columns, sorting, in-place editing · ComboBox — the same list, collapsed · 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