ImGuiWindow: Checkbox Asynchronous
Add an on/off control with an initial state. Keep the boolean passed to the callback if the rest of your script needs the updated setting.
Luau
ImGuiWindow:Checkbox(
label: string,
checked: any?,
callback: (boolean) -> ()
) -> ImGuiWindowParameters
Call this method with a ImGuiWindow receiver. The colon supplies self implicitly; a dot call must pass the receiver explicitly.
| Parameter | Type | Description |
|---|---|---|
label | string | Text displayed beside the checkbox. |
checked | any? | Initial state; false and nil are unchecked, while other values are checked. |
callback | (boolean) -> () | Function receiving the new checked state as a boolean. |
Returns
ImGuiWindowThe same ImGuiWindow handle, so more controls can be added with another method call.
Usage notes
The callback runs when the user interacts with the control. Its return value is ignored.
Example
Luau
local window = imgui.create("Example controls")
local settings = { showLabels = true }
window:Checkbox("Show labels", settings.showLabels, function(checked)
settings.showLabels = checked
print("Labels enabled:", checked)
end)