The nth node with this role.
- ui: the UI to search.
- role: the role to match.
- index: which match to take, from 0.
ui := headless(.{ width = 320, height = 200 });
defer free_ui(*ui);
count := 0;
build := (n: *int) {
for column(.{ gap = 8, padding = 16 }) {
label(tprint("Clicked % times", n.*));
if button("Add") n.* += 1;
}
};
frame(*ui, *count, build);
assert(find_role(*ui, .TEXT).text == "Clicked 0 times");
assert(find_role(*ui, .BUTTON) != null);find_role :: (ui: *UI_State, role: Role, index: int = 0) -> *Node
The nth node with this role.
Parameters
- ui: *UI_State
- the UI to search.
- role: Role
- the role to match.
- index: int = 0
- which match to take, from 0.
Returns
- *Node
ui := headless(.{ width = 320, height = 200 });
defer free_ui(*ui);
count := 0;
build := (n: *int) {
for column(.{ gap = 8, padding = 16 }) {
label(tprint("Clicked % times", n.*));
if button("Add") n.* += 1;
}
};
frame(*ui, *count, build);
assert(find_role(*ui, .TEXT).text == "Clicked 0 times");
assert(find_role(*ui, .BUTTON) != null);