UI module

click

procedureextensionexperimentalsince 0.31.0Source

Move the pointer to the centre of node and click it. The next frame applies it and shows the result. node must come from a frame that has already laid it out.

Example↗
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);
click(*ui, find_label(*ui, "Add"));
frame(*ui, *count, build);
assert(count == 1);
click :: (ui: *UI_State, node: *Node)

Move the pointer to the centre of node and click it. The next frame applies it and shows the result. node must come from a frame that has already laid it out.

Parameters

ui: *UI_State
the UI to send the click to.
node: *Node
the node to click. Null does nothing.
Example↗
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);
click(*ui, find_label(*ui, "Add"));
frame(*ui, *count, build);
assert(count == 1);

See also