> For the complete documentation index, see [llms.txt](https://docs.quickclient.cc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.quickclient.cc/en/settings/custom.md).

# Entries with their own drawing

A setting that the script draws itself and handles clicks for.

If the standard settings are not enough, a script can draw its own entry. `custom(name, height)` reserves a strip of the given height in the settings window, and the script handles drawing and clicks itself. You can use it for a slider with a preview, a palette or a small chart.

```java
private float volume = 0.5f;

private final Custom bar = custom("Volume", 16f)
        .onDraw(canvas -> {
            Render2D render = canvas.render();
            render.drawClientRect(canvas.x(), canvas.y() + 6f, canvas.width(), 4f, 2f, canvas.fade(0x60FFFFFF));
            render.drawClientRect(canvas.x(), canvas.y() + 6f, canvas.width() * volume, 4f, 2f,
                    canvas.fade(render.themeColor("basic")));
        })
        .onClick((mouseX, mouseY, button) -> {
            volume = mouseX;
            return true;
        })
        .persist(() -> String.valueOf(volume), raw -> volume = Float.parseFloat(raw));
```

## How it works

* `onDraw` draws a grey bar across the full width, and the filled part on top of it in the theme color.
* `onClick` takes `mouseX` as the new volume. The coordinate is already between 0 and 1, so there is nothing to convert.
* `persist` saves the volume as a string and reads it back on load.

## Custom

| Method                 | Type     | Description                                                     |
| ---------------------- | -------- | --------------------------------------------------------------- |
| `height()`             | `float`  | height of the strip                                             |
| `height(value)`        | `Custom` | change the height                                               |
| `onDraw(op)`           | `Custom` | drawing, receives a `Canvas`                                    |
| `onClick(op)`          | `Custom` | mouse press; return `true` to stop the click from going further |
| `onRelease(op)`        | `Custom` | mouse release                                                   |
| `persist(write, read)` | `Custom` | saving the value to the config                                  |

In `onClick` and `onRelease` coordinates are given as fractions of the area: 0 is the left or top edge, 1 is the right or bottom edge. Buttons: 0 left, 1 right, 2 middle.

Without `persist` the value is kept only until a reload. With it, Quick writes the string from `write` to the config and passes it to `read` on load. Everything else from [Kinds of settings](/en/settings/types.md) works as usual: `id`, `description`, `visibleWhen` and nesting inside a checkbox.

## Canvas

Canvas describes the area Quick reserved for the setting in the current frame.

| Method                 | Type       | Description                                                              |
| ---------------------- | ---------- | ------------------------------------------------------------------------ |
| `render()`             | `Render2D` | the same `Render2D` as for the HUD, see [2D render](/en/ui/render-2d.md) |
| `x()`, `y()`           | `float`    | top left corner                                                          |
| `width()`, `height()`  | `float`    | size                                                                     |
| `mouseX()`, `mouseY()` | `float`    | cursor in the same coordinates                                           |
| `hovered()`            | `boolean`  | whether the cursor is inside the area                                    |
| `alpha()`              | `float`    | opacity of the settings window, 0..1                                     |
| `fade(color)`          | `int`      | color multiplied by `alpha()`                                            |

The settings window fades in. If you draw with a color without `fade`, your entry becomes visible before the window itself.

The `Render2D` from `Canvas` is valid for one frame only, just like on the HUD, so you cannot store it in a field.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.quickclient.cc/en/settings/custom.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
