Syntax
ImGuiWindow.ColorPicker(window: ImGuiWindow, label: string, red?: number, green?: number, blue?: number, alpha?: number, onChange: function): ImGuiWindowArguments
| Name | Type | Description |
|---|---|---|
window | ImGuiWindow | ImGuiWindow object returned by imgui.create. A destroyed or invalid window raises a Lua error. |
label | string | Color editor label string passed to the rendered ImGui ColorEdit4 widget. |
red? | number | Initial red component read with luaL_optnumber; defaults to 1.0 when omitted or nil. |
green? | number | Initial green component read with luaL_optnumber; defaults to 1.0 when omitted or nil. |
blue? | number | Initial blue component read with luaL_optnumber; defaults to 1.0 when omitted or nil. |
alpha? | number | Initial alpha component read with luaL_optnumber; defaults to 1.0 when omitted or nil. |
onChange | function | Function stored for this color editor and invoked with red, green, blue, and alpha after a change event is processed. It must be supplied as argument 7. |
Returns
| Name | Type | Description |
|---|---|---|
window | ImGuiWindow | The same ImGuiWindow object, allowing chained method calls. |
Description
Appends a RGBA color editor to an ImGuiWindow and stores the callback. Missing or nil color components default to 1.0. When the rendered editor changes, the callback is queued and later invoked with red, green, blue, and alpha. The method returns the same ImGuiWindow object.
Call it with 7 parameter(s): window, label, red, green, blue, alpha, onChange. 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
Example call with placeholder values.
local result = ImGuiWindow.ColorPicker(nil, "example", 1, 1, 1, 1, function() end)
print(result)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 queues the callback with no arguments after a click.Checkbox (label: string, checked: any, onChange: (boolean) -> ()) -> ImGuiWindow Appends a checkbox initialized from the checked value.CollapsingHeader (label: string, content: (ImGuiWindow) -> ()) -> ImGuiWindow Immediately runs content to append elements that render under a collapsible header.ColorPicker (label: string, red: number?, green: number?, blue: number?, alpha: number?, onChange: (number, number, number, number) -> ()) -> ImGuiWindow Appends a ColorEdit4-backed RGBA editor; onChange is read from argument 7.InputText (label: string, text: string?, onChange: (string) -> ()) -> ImGuiWindow Appends a single-line InputText using a fixed 256-byte buffer; onChange is argument 4.SameLine () -> ImGuiWindow Appends a SameLine layout marker that calls same-line layout during rendering.Separator () -> ImGuiWindow Appends a Separator marker that calls a separator during rendering.SliderFloat (label: string, value: number, minimum: number, maximum: number, onChange: (number) -> ()) -> ImGuiWindow Appends a SliderFloat element and queues onChange with one Lua number when the value changes.SliderInt (label: string, value: integer, minimum: integer, maximum: integer, onChange: (number) -> ()) -> ImGuiWindow Appends a SliderInt element and queues onChange with one Lua number when the integer value changes.Text (text: string) -> ImGuiWindow Appends a non-interactive text element.destroy () -> () Removes the window and releases its registered callbacks.