Skip to content

Checkboxes

Toggle checkboxes for on/off options.

Creating a Checkbox

let checkbox = gui_checkbox("Enable feature");

Getting State

let is_checked = gui_get_checked(checkbox);
if is_checked == true {
    print "Checkbox is checked";
}

Setting State

gui_set_checked(checkbox, true);   // Check
gui_set_checked(checkbox, false);  // Uncheck

Example

gui_init("com.example.checkbox");

let window = gui_window("Checkbox Demo", 300, 200);
let box = gui_box("vertical", 10);

let checkbox = gui_checkbox("Accept terms");
let button = gui_button("Submit");
let result = gui_label("");

fn submit() {
    let accepted = gui_get_checked(checkbox);
    if accepted == true {
        gui_set_text(result, "Terms accepted!");
    } else {
        gui_set_text(result, "Please accept terms");
    }
}

gui_on(button, "clicked", "submit");

gui_add(box, checkbox);
gui_add(box, button);
gui_add(box, result);
gui_add(window, box);
gui_run();