How find picks a node: every field that is set must match.
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);
node := find(*ui, .{ role = .BUTTON, match_role = true });
assert(node != null && node.label == "Add");
assert(find(*ui, .{ text = "no such text" }) == null);Fields
- label: string
- the node's label
- text: string
- the text it draws
- role: Role
- match_role: bool
rolecounts- index: int
- the nth match, from 0