One tab in a tab_bar, drawn selected when active.
- text: the tab's title. It is copied for the frame.
- active: whether this is the selected tab.
- options: whether it shows an unsaved dot or a close button.
- loc: the call site. It identifies the widget from one frame to the next, so leave the default.
current := 0;
ui := headless();
defer free_ui(*ui);
build := (selected: *int) {
for tab_bar() {
if tab("One", selected.* == 0) == .SELECT selected.* = 0;
if tab("Two", selected.* == 1) == .SELECT selected.* = 1;
}
};
frame(*ui, *current, build);
click(*ui, find_label(*ui, "Two"));
frame(*ui, *current, build);
assert(current == 1);tab :: (
text: string,
active: bool,
options: Tab_Options = .{},
loc := #caller_location
) -> Tab_Result
One tab in a tab_bar, drawn selected when active.
Parameters
- text: string
- the tab's title. It is copied for the frame.
- active: bool
- whether this is the selected tab.
- options: Tab_Options = .{}
- whether it shows an unsaved dot or a close button.
- loc := #caller_location
- the call site. It identifies the widget from one frame to the next, so leave the default.
Returns
current := 0;
ui := headless();
defer free_ui(*ui);
build := (selected: *int) {
for tab_bar() {
if tab("One", selected.* == 0) == .SELECT selected.* = 0;
if tab("Two", selected.* == 1) == .SELECT selected.* = 1;
}
};
frame(*ui, *current, build);
click(*ui, find_label(*ui, "Two"));
frame(*ui, *current, build);
assert(current == 1);