ImGui

imgui.create

Creates an ImGui window and returns its window handle. Active window titles must be unique.

Syntax

imgui.create(title?: string): ImGuiWindow

Arguments

NameTypeDescription
title?stringWindow title. When omitted, the built-in default title is used. Creating a second active window with the same title raises an error.

Returns

NameTypeDescription
windowImGuiWindowWindow handle used to append controls and destroy the window.

Description

Creates an ImGui window and returns its window handle. Active window titles must be unique.

Call it with 1 parameter(s): title. The argument table explains which values are required and which ones only refine the behavior.

It returns window (ImGuiWindow). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Build an ImGui window with text, interactive controls, and change callbacks.

local window = imgui.create("Runtime settings")

window:Text("Controls")
window:Separator()

window:Checkbox("Enabled", true, function(enabled)
    print("Enabled:", enabled)
end)

window:SliderFloat("Opacity", 0.8, 0, 1, function(value)
    print("Opacity:", value)
end)

window:InputText("Label", "Real", function(text)
    print("Label:", text)
end)

window:ColorPicker("Accent", 0.3, 0.6, 1, 1, function(red, green, blue, alpha)
    print(red, green, blue, alpha)
end)

window:CollapsingHeader("Advanced", function(section)
    section:Text("Advanced controls go here")
end)

Types

ImGuiWindow

Handle returned by imgui.create. Control-building methods return the same handle so calls can be chained.

Button (label: string, onClick: () -> ()) -> ImGuiWindow Appends a button and invokes the callback after a click.Checkbox (label: string, checked: boolean, onChange: (boolean) -> ()) -> ImGuiWindow Appends a checkbox initialized to the provided state.CollapsingHeader (label: string, content: (ImGuiWindow) -> ()) -> ImGuiWindow Groups controls appended by the content callback beneath a collapsing header.ColorPicker (label: string, red: number?, green: number?, blue: number?, alpha: number?, onChange: (number, number, number, number) -> ()) -> ImGuiWindow Appends an RGBA editor; omitted color components default to 1.0.InputText (label: string, text: string?, onChange: (string) -> ()) -> ImGuiWindow Appends a single-line text input; omitted initial text defaults to an empty string.SameLine () -> ImGuiWindow Places the next control on the same line.Separator () -> ImGuiWindow Appends a horizontal separator.SliderFloat (label: string, value: number, minimum: number, maximum: number, onChange: (number) -> ()) -> ImGuiWindow Appends a floating-point slider.SliderInt (label: string, value: integer, minimum: integer, maximum: integer, onChange: (number) -> ()) -> ImGuiWindow Appends an integer slider.Text (text: string) -> ImGuiWindow Appends non-interactive text.destroy () -> () Removes the window and releases its registered callbacks.