> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# ImGuiWindow.ColorPicker

> 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.

<div className="real-function-page">
  ```lua theme={null}
  ImGuiWindow.ColorPicker(window: ImGuiWindow, label: string, red?: number, green?: number, blue?: number, alpha?: number, onChange: function): ImGuiWindow
  ```

  ## 参数

  <ParamField path={"window"} type={"ImGuiWindow"} required>
    ImGuiWindow object returned by imgui.create. A destroyed or invalid window raises a Lua error.
  </ParamField>

  <ParamField path={"label"} type={"string"} required>
    Color editor label string passed to the rendered ImGui ColorEdit4 widget.
  </ParamField>

  <ParamField path={"red"} type={"number"}>
    Initial red component read with luaL\_optnumber; defaults to 1.0 when omitted or nil.
  </ParamField>

  <ParamField path={"green"} type={"number"}>
    Initial green component read with luaL\_optnumber; defaults to 1.0 when omitted or nil.
  </ParamField>

  <ParamField path={"blue"} type={"number"}>
    Initial blue component read with luaL\_optnumber; defaults to 1.0 when omitted or nil.
  </ParamField>

  <ParamField path={"alpha"} type={"number"}>
    Initial alpha component read with luaL\_optnumber; defaults to 1.0 when omitted or nil.
  </ParamField>

  <ParamField path={"onChange"} type={"function"} required>
    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.
  </ParamField>

  ## 返回值

  <ResponseField name={"window"} type={"ImGuiWindow"}>
    The same ImGuiWindow object, allowing chained method calls.
  </ResponseField>

  ## 类型

  ### ImGuiWindow

  imgui.create 返回的句柄。控制构建方法返回相同的句柄，因此可以链接调用。

  | Name               | Type                                                                                                                                            | Required | 说明                        |
  | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------- |
  | `Button`           | `(label: string, onClick: () -> ()) -> ImGuiWindow`                                                                                             | Yes      | 添加一个按钮并在单击后调用回调。          |
  | `Checkbox`         | `(label: string, checked: any, onChange: (boolean) -> ()) -> ImGuiWindow`                                                                       | Yes      | 附加一个初始化为提供状态的复选框。         |
  | `CollapsingHeader` | `(label: string, content: (ImGuiWindow) -> ()) -> ImGuiWindow`                                                                                  | Yes      | 对折叠标题下方的内容回调附加的控件进行分组。    |
  | `ColorPicker`      | `(label: string, red: number?, green: number?, blue: number?, alpha: number?, onChange: (number, number, number, number) -> ()) -> ImGuiWindow` | Yes      | 追加RGBA编辑器；省略的颜色分量默认为 1.0。 |
  | `InputText`        | `(label: string, text: string?, onChange: (string) -> ()) -> ImGuiWindow`                                                                       | Yes      | 追加单行文本输入；省略的初始文本默认为空字符串。  |
  | `SameLine`         | `() -> ImGuiWindow`                                                                                                                             | Yes      | 将下一个控件放置在同一行上。            |
  | `Separator`        | `() -> ImGuiWindow`                                                                                                                             | Yes      | 添加水平分隔符。                  |
  | `SliderFloat`      | `(label: string, value: number, minimum: number, maximum: number, onChange: (number) -> ()) -> ImGuiWindow`                                     | Yes      | 添加浮点滑块。                   |
  | `SliderInt`        | `(label: string, value: integer, minimum: integer, maximum: integer, onChange: (number) -> ()) -> ImGuiWindow`                                  | Yes      | 附加一个整数滑块。                 |
  | `Text`             | `(text: string) -> ImGuiWindow`                                                                                                                 | Yes      | 附加非交互式文本。                 |
  | `destroy`          | `() -> ()`                                                                                                                                      | Yes      | 删除窗口并释放其注册的回调。            |
</div>
