> For the complete documentation index, see [llms.txt](https://0x29a.gitbook.io/0x29a-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://0x29a.gitbook.io/0x29a-docs/interface/ui.md).

# ui

**interface · ImGui (immediate mode) · global: `ui`**

A direct binding of [Dear ImGui](https://github.com/ocornut/imgui) — windows, widgets, tables and draw lists, in the same *immediate mode* style as ImGui in C++: you call these functions every frame, inside `_29a.on_frame`, and the UI "is" whatever you called that frame.

```lua
_29a.on_frame(function()
    if ui.begin("My Menu") then
        ui.text("hello!")
        if ui.button("click here") then
            print("clicked")
        end
    end
    ui.finish()
end)
```

{% hint style="info" %}
`ui.finish()` exists because `end` is a reserved word in Lua — it maps to `ImGui::End()` and must always be called, even when `ui.begin` returned `false` (window collapsed/off-screen) — same as in ImGui in C++.
{% endhint %}

## Window

### `ui.begin(name [, flags]) -> bool`

Opens (or continues) a window. `flags` is a bitwise combination of [`ui.Flag.*`](#ui-flag). Returns `false` if the window is collapsed — your content can be skipped, but `ui.finish()` must **always** be called.

### `ui.finish()`

Closes the window opened by `ui.begin`. *(`ImGui::End`)*

### `ui.set_next_window_pos(x, y [, cond])`

### `ui.set_next_window_size(w, h [, cond])`

Sets the position/size of the **next** window to be opened. `cond` is an `ImGuiCond` (default: always apply).

### `ui.begin_child(id [, w=0, h=0, border=false]) -> bool`

### `ui.end_child()`

A sub-region with independent scrolling inside the current window.

### `ui.set_cursor_screen_pos(x, y)`

### `ui.get_cursor_screen_pos() -> x, y`

Reads/moves the draw cursor in absolute screen coordinates.

### `ui.scroll_y([y]) -> current, max`

With no argument, returns the current vertical scroll and the max. With `y`, sets the scroll.

## Text

### `ui.text(str)`

### `ui.text_colored(str, r, g, b [, a=1])`

Colors are `0..1` floats, not `0..255`.

### `ui.text_size(str [, font]) -> w, h`

Measures the text without drawing it, in the given font (see [Fonts](#fonts)).

### `ui.separator()`

### `ui.same_line([offset=0, spacing=-1])`

### `ui.spacing()`

## Widgets

### `ui.button(label [, w=0, h=0]) -> clicked`

### `ui.checkbox(label, value) -> new_value, changed`

### `ui.slider_float(label, value, min, max) -> new_value, changed`

### `ui.input_text(label, current) -> new_text, changed`

Fixed internal 1024-byte buffer.

### `ui.input_int(label, value) -> new_value, changed`

Common pattern — the value always comes back as the first return, and `changed` tells you whether to persist it with [`save.set`](/0x29a-docs/data-and-platform/save.md):

```lua
local sensitivity = save.get("sensitivity", 1.0)
local changed
sensitivity, changed = ui.slider_float("Sensitivity", sensitivity, 0.1, 5.0)
if changed then save.set("sensitivity", sensitivity) end
```

## Tree

### `ui.tree_node(label) -> open`

### `ui.tree_pop()`

Only call `tree_pop` when `tree_node` returned `true` (same as ImGui in C++).

## Columns & tables

### `ui.columns([n=1, id, border=false])`

### `ui.next_column()`

Legacy columns API — for new layouts, prefer `begin_table`.

### `ui.begin_table(id, columns) -> bool`

### `ui.end_table()`

### `ui.table_next_row()`

### `ui.table_next_column()`

### `ui.table_setup_column(label)`

### `ui.table_headers_row()`

```lua
if ui.begin_table("stats", 2) then
    ui.table_setup_column("Name")
    ui.table_setup_column("Value")
    ui.table_headers_row()

    ui.table_next_row()
    ui.table_next_column(); ui.text("FPS")
    ui.table_next_column(); ui.text(tostring(ui.framerate()))

    ui.end_table()
end
```

## Draw list (current window)

Draws on the **current ImGui window's** draw list — respects clipping and z-order inside it. For full-screen HUD/ESP that doesn't depend on a window, use [render](/0x29a-docs/interface/render.md) instead.

Every color is `r, g, b [, a=1]` in `0..1`.

### `ui.dl_rect_filled(x, y, w, h, r, g, b [, a, thickness_ignored, rounding])`

### `ui.dl_rect(x, y, w, h, r, g, b [, a, thickness=1, rounding])`

### `ui.dl_line(x1, y1, x2, y2, r, g, b [, a, thickness=1])`

### `ui.dl_triangle_filled(x1, y1, x2, y2, x3, y3, r, g, b [, a])`

### `ui.dl_circle_filled(x, y, radius, r, g, b [, a])`

### `ui.dl_text(x, y, r, g, b [, a], text [, font])`

{% hint style="warning" %}
The alpha argument is optional but **positional**: if you skip it, `text` must come right after `b` (argument 6); if you pass `a`, `text` becomes argument 7. For plain text without worrying about this, prefer [`render.text`](/0x29a-docs/interface/render.md#render-text-x-y-color-text).
{% endhint %}

\### \`ui.push\_clip(x, y, w, h)\` ### \`ui.pop\_clip()\`

## Fonts

### `ui.font_get(name) -> index | nil`

Resolves an already-registered font (`"main"`, `"small"`, `"bold"`, `"big"`, or any name loaded via `font_load`) to the index used by `dl_text`/`text_size`.

### `ui.font_load(name, file [, size_px=14, icons=false]) -> index | nil`

Loads a `.ttf` font from `file` under the name `name`. `icons=true` merges an icon glyph range into the atlas (for icon fonts).

### `ui.font_count() -> integer`

## Style

### `ui.push_style_color(col_id, r, g, b [, a=1])`

`col_id` comes from [`ui.Col.*`](#ui-col).

### `ui.pop_style_color([count=1])`

## Input capture & mouse priority

### `ui.capture_input(enabled)`

Asks the overlay to route mouse/keyboard to ImGui as if the main menu were open — use this for a menu built by your own script, independent of the native INSERT menu.

```lua
bind(input.KEY.F2, function()
    menu_open = not menu_open
    ui.capture_input(menu_open)
end)
```

### `ui.mouse_priority([enabled]) -> current`

Controls whether the overlay claims **full mouse priority** the instant a menu is open (`true`, default) or only while the cursor is literally over an ImGui window (`false` — click-through outside the UI). Called with no argument, it just reads the current value without changing it. See [Hotkeys → mouse priority](/0x29a-docs/introduction/hotkeys.md#mouse-priority-while-the-menu-is-open).

## Hex viewer

### `ui.hex_view(addr [, size=256])`

Opens the overlay's native hex-viewer tab already positioned at `addr`.

## Misc

### `ui.is_key_pressed(key) -> bool`

`key` is a value from [`ui.Key.*`](#ui-key) (not to be confused with [`input.KEY.*`](/0x29a-docs/runtime/input.md#input-key), which are Windows virtual-keys — this is the `ImGuiKey` enum, only meaningful while the UI has focus).

### `ui.framerate() -> number`

The overlay's FPS (not the game's).

### `ui.get_window_pos() -> x, y`

### `ui.get_window_size() -> w, h`

### `ui.is_window_focused() -> bool`

### `ui.is_window_hovered() -> bool`

### `ui.get_io_display_size() -> w, h`

Overlay's screen/viewport resolution.

### `ui.mouse() -> x, y`

Mouse position relative to ImGui (equivalent to `input.mouse()` but via `ImGuiIO`).

### `ui.mouse_down([button=0]) -> bool`

### `ui.clicked([button=0]) -> bool`

`button`: `0` left, `1` right, `2` middle.

## `ui.Key`

A subset of `ImGuiKey` exposed for `ui.is_key_pressed`: `Insert Delete F1`…`F12` `Home End PageUp PageDown`.

## `ui.Col`

A subset of `ImGuiCol` for `ui.push_style_color`: `Text WindowBg Button ButtonHovered ButtonActive Header HeaderHovered FrameBg TitleBg TitleBgActive`.

## `ui.Flag`

A subset of `ImGuiWindowFlags` for `ui.begin`: `NoTitleBar NoResize NoMove NoScrollbar NoCollapse NoBackground NoSavedSettings NoDecoration NoInputs NoBringToFrontOnFocus`. Combine with `+` or `|` depending on your Lua/bitop.

```lua
ui.begin("HUD", ui.Flag.NoTitleBar + ui.Flag.NoResize + ui.Flag.NoMove)
```


---

# 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://0x29a.gitbook.io/0x29a-docs/interface/ui.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.
