# ColorPickerButton

## ColorPickerButton

The [`ColorPickerButton`](https://github.com/V-Fast/DynamicHUD/blob/master/src/main/java/com/tanishisherewith/dynamichud/util/colorpicker/ColorPickerButton.java) class provides functionality for creating and displaying color picker buttons in Minecraft Fabric.

### Fields

* `x`: The x position of the button.
* `y`: The y position of the button.
* `width`: The width of the button.
* `height`: The height of the button.
* `isPicking`: Whether the button is currently in picking mode.

### Constructors

#### ColorPickerButton(int x, int y, int width, int height)

Constructs a `ColorPickerButton` object with the given position and size.

### Methods

#### render(MatrixStack matrices)

Renders this button on screen.

#### onClick(double mouseX, double mouseY, int button)

Handles mouse clicks on this button. This method sets the picking mode to true if the mouse is over the button and the left mouse button was clicked.

#### isPicking()

Returns whether this button is currently in picking mode.

#### setPicking(boolean picking)

Sets whether this button is currently in picking mode.

The ColorPickerButton is already called and present in [ColorGradientPicker](/archived-legacy-dynamichud/colorpicker/colorgradientpicker.md). But if you still want to add it yourself somewhere you can do it by:

```java
// Create a new ColorPickerButton
ColorPickerButton button = new ColorPickerButton(10, 10, 100, 20);

// Render the ColorPickerButton
button.render(matrices);

// Handle mouse input
if (button.onClick(mouseX, mouseY)) {
    // The mouse was clicked on the button
}
```

In this example, we create a new `ColorPickerButton` with a position of (10, 10) and a size of (100, 20). We then render the `ColorPickerButton` on screen using its `render` method. We also handle mouse input by calling its `onClick` method.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tanishisherewith.gitbook.io/archived-legacy-dynamichud/colorpicker/colorgradientpicker/colorpickerbutton.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
