UI module

checkbox

procedureextensionexperimentalsince 0.31.0Source

A checkbox with a caption. Returns true on the frame the value changed.

Example↗
on := false;
ui := headless();
defer free_ui(*ui);
build := (value: *bool) { checkbox(value, "Dark mode"); };
frame(*ui, *on, build);
click(*ui, find_role(*ui, .CHECKBOX));
frame(*ui, *on, build);
assert(on);
checkbox :: (
    value: *bool,
    text: string = "",
    loc := #caller_location
) -> changed: bool

A checkbox with a caption. Returns true on the frame the value changed.

Parameters

value: *bool
the flag to show and toggle. It is changed in place.
text: string = ""
a caption next to the box. Empty for none.
loc := #caller_location
the call site. It identifies the widget from one frame to the next, so leave the default.

Returns

changed: bool
Example↗
on := false;
ui := headless();
defer free_ui(*ui);
build := (value: *bool) { checkbox(value, "Dark mode"); };
frame(*ui, *on, build);
click(*ui, find_role(*ui, .CHECKBOX));
frame(*ui, *on, build);
assert(on);

See also