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.

Syntax
Luau
ImGuiWindow:Button(label: string, callback: () -> ()) -> ImGuiWindow

Parameters

Call this method with a ImGuiWindow receiver. The colon supplies self implicitly; a dot call must pass the receiver explicitly.

Function parameters
ParameterTypeDescription
labelstringText shown on the button.
callback() -> ()Function called with no arguments when the button is activated.

Returns

ImGuiWindow

The 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

Example
Luau
local window = imgui.create("Example controls")
window:Button("Save example", function()
    writefile("example-settings.json", json.encode({ theme = "dark" }))
    print("Saved")
end)
Kawaii documentation