UI module

find

procedureextensionexperimentalsince 0.31.0Source

The first node matching query, in tree order, or null.

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);
text := find(*ui, .{ text = "Clicked 0 times" });
assert(text != null);
find :: (ui: *UI_State, query: Find_Query) -> *Node

The first node matching query, in tree order, or null.

Parameters

ui: *UI_State
the UI to search.
query: Find_Query
what the node must match.

Returns

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);
text := find(*ui, .{ text = "Clicked 0 times" });
assert(text != null);

See also