Give keyboard focus to node.
- ui: the UI the node belongs to.
- node: the node to focus.
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);
focus_node(*ui, find_label(*ui, "Add"));
frame(*ui, *count, build);
assert(events_of(*ui, find_label(*ui, "Add")).focused);focus_node :: (ui: *UI_State, node: *Node)
Give keyboard focus to node.
Parameters
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);
focus_node(*ui, find_label(*ui, "Add"));
frame(*ui, *count, build);
assert(events_of(*ui, find_label(*ui, "Add")).focused);