A row in a list or tree: highlighted when selected, indented by indent points. Returns true
when clicked.
- text: the row's text. It is copied for the frame.
- selected: whether to draw it highlighted.
- indent: extra space on the left, in points.
- loc: the call site. It identifies the widget from one frame to the next, so leave the default.
selected := -1;
ui := headless();
defer free_ui(*ui);
build := (choice: *int) {
for column() {
for 0..2 {
if list_item(tprint("Item %", it), choice.* == it) choice.* = it;
}
}
};
frame(*ui, *selected, build);
click(*ui, find_label(*ui, "Item 1"));
frame(*ui, *selected, build);
assert(selected == 1);list_item :: (
text: string,
selected: bool = false,
indent: float = 0,
loc := #caller_location
) -> clicked: bool
A row in a list or tree: highlighted when selected, indented by indent points. Returns true
when clicked.
Parameters
- text: string
- the row's text. It is copied for the frame.
- selected: bool = false
- whether to draw it highlighted.
- indent: float = 0
- extra space on the left, in points.
- loc := #caller_location
- the call site. It identifies the widget from one frame to the next, so leave the default.
Returns
- clicked: bool
selected := -1;
ui := headless();
defer free_ui(*ui);
build := (choice: *int) {
for column() {
for 0..2 {
if list_item(tprint("Item %", it), choice.* == it) choice.* = it;
}
}
};
frame(*ui, *selected, build);
click(*ui, find_label(*ui, "Item 1"));
frame(*ui, *selected, build);
assert(selected == 1);