ImGuiWindow: Button Asynchronous
Add a button and run a callback when it is activated. Use it for an action the user explicitly starts, such as saving the current settings. The callback runs on activation, not when the button is added.
Luau
ImGuiWindow:Button(label: string, callback: () -> ()) -> 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 shown on the button. |
callback | () -> () | Function called with no arguments when the button is activated. |
Returns
ImGuiWindowThe same ImGuiWindow, allowing another window method to be chained.
Usage notes
Interaction callbacks run when the control is used. Their return values are discarded.
Example
Luau
local window = imgui.create("Example controls")
window:Button("Save example", function()
writefile("example-settings.json", json.encode({ theme = "dark" }))
print("Saved")
end)