# ui

## Example available!

{% content-ref url="../../useful-information/examples/ui-interaction" %}
[ui-interaction](../../useful-information/examples/ui-interaction)
{% endcontent-ref %}

## Elements:

### add\_checkbox

`ui.add_checkbox(name: string):` <mark style="color:purple;">`MenuItem`</mark>

| Name     | Type         | Description |
| -------- | ------------ | ----------- |
| **name** | **`string`** | Item name   |

Creates and returns a menu item object, or throws an error on failure.

### add\_combobox

`ui.add_combobox(name: string, items: {, ...}):` <mark style="color:purple;">`MenuItem`</mark>

| Name      | Type         | Description |
| --------- | ------------ | ----------- |
| **name**  | **`string`** | Item name   |
| **items** | **`string`** | Items       |

Creates and returns a menu item object, or throws an error on failure.

### add\_sliderint

`ui.add_sliderint(name: string, min: number, max: number):` <mark style="color:purple;">`MenuItem`</mark>

| Name     | Type         | Description   |
| -------- | ------------ | ------------- |
| **name** | **`string`** | Item name     |
| **min**  | **`number`** | Minimum value |
| **max**  | **`number`** | Maximum value |

Creates and returns a menu item object, or throws an error on failure.

### add\_sliderfloat

`ui.add_sliderfloat(name: string, min: number, max: number):` <mark style="color:purple;">`MenuItem`</mark>

| Name     | Type         | Description   |
| -------- | ------------ | ------------- |
| **name** | **`string`** | Item name     |
| **min**  | **`number`** | Minimum value |
| **max**  | **`number`** | Maximum value |

Creates and returns a menu item object, or throws an error on failure.

### add\_button

`ui.add_button(name: string):` <mark style="color:purple;">`MenuItem`</mark>

| Name     | Type         | Description |
| -------- | ------------ | ----------- |
| **name** | **`string`** | Item name   |

Creates and returns a menu item object, or throws an error on failure.

### add\_colorpicker

`ui.add_colorpicker(name: string):` <mark style="color:purple;">`MenuItem`</mark>

| Name     | Type         | Description |
| -------- | ------------ | ----------- |
| **name** | **`string`** | Item name   |

Creates and returns a menu item object, or throws an error on failure.

### add\_label

`ui.add_label(name: string):` <mark style="color:purple;">`MenuItem`</mark>

| Name     | Type         | Description |
| -------- | ------------ | ----------- |
| **name** | **`string`** | Item name   |

Creates and returns a menu item object, or throws an error on failure.

### add\_hotkey

`ui.add_hotkey(name: string):` <mark style="color:purple;">`MenuItem`</mark>

| Name     | Type         | Description |
| -------- | ------------ | ----------- |
| **name** | **`string`** | Item name   |

Creates and returns a menu item object, or throws an error on failure.

### add\_input

`ui.add_input(name: string):` <mark style="color:purple;">`MenuItem`</mark>

| Name     | Type         | Description |
| -------- | ------------ | ----------- |
| **name** | **`string`** | Item name   |

Creates and returns a menu item object, or throws an error on failure.

### get\_keybind\_state

`ui.get_keybind_state(name: string)`

| Name     | Type         | Description |
| -------- | ------------ | ----------- |
| **name** | **`string`** | Item name   |

Returns <mark style="color:green;">`true`</mark>, if keybind is active.

### get\_keybind\_mode

`ui.get_keybind_mode(name: string)`

| Name     | Type         | Description |
| -------- | ------------ | ----------- |
| **name** | **`string`** | Item name   |

Returns the keybind mode.

### set\_keybind\_state

`ui.set_keybind_state(name: string, var: boolean)`

| Name     | Type          | Description |
| -------- | ------------- | ----------- |
| **name** | **`string`**  | Item name   |
| **var**  | **`boolean`** | Item var    |

Sets the keybind boolean value.

## Functions:

### :get

`<element>:get():` <mark style="color:purple;">`any`</mark>&#x20;

Returns the value of the menu item.

### :set

`<element>:set(value: any)`&#x20;

<table><thead><tr><th width="151">Name</th><th width="173">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>value</strong></td><td><strong><code>any</code></strong></td><td>The value to which the menu item will be set</td></tr></tbody></table>

Sets the value of the menu item.

### :set\_visible

`<element>:set_visible(state: boolean)`

| Name      | Type          | Description          |
| --------- | ------------- | -------------------- |
| **state** | **`boolean`** | New visibility state |

Shows or hides the menu item depending on the value of `state`.

### :set\_callback

{% hint style="warning" %}
Works only in callbacks.
{% endhint %}

`<element>:set_callback(callback: function)`

<table><thead><tr><th width="163">Name</th><th width="158">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>callback</strong></td><td><strong><code>function</code></strong></td><td>Function that will be called when the menu item is interacted with</td></tr></tbody></table>

```lua
local checkbox = ui.add_checkbox("Checkbox")

cheat.push_callback("on_paint", function()
    checkbox:set_callback(function()
        cheat.notify("Callback")
    end)
end)
```

Sets the callback to the specified menu item.

### :set\_group

`<element>:set_group(group: number)`

| Name      | Type         | Description                                                                                                                              |
| --------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| **group** | **`number`** | <p><mark style="color:purple;"><code>1</code></mark> - Left group<br><mark style="color:purple;"><code>2</code></mark> - Right group</p> |

Sets the group to the specified menu item.

## Combobox additive functions:

### :set\_items

`<element>:set_items(items: {, ...})`

| Name      | Type         | Description              |
| --------- | ------------ | ------------------------ |
| **items** | **`string`** | Table with string values |

Sets a table with items. `ui.add_combobox` menu item objects only.

### :get\_items

`<element>:get_items():` <mark style="color:purple;">`table`</mark>&#x20;

Returns the table of items. `ui.add_combobox` menu item objects only.

## Hotkey additive functions:

### :get\_mode

`<element>:get_mode():` <mark style="color:purple;">`number`</mark>&#x20;

Returns the current keybind mode. `ui.add_hotkey` menu item objects only.

## Find menu items:

{% tabs %}
{% tab title="int" %}
`ui.find_menu_int(item_name: string):` <mark style="color:purple;">`MenuItem`</mark>

| Name           | Type         | Description |
| -------------- | ------------ | ----------- |
| **item\_name** | **`string`** | -           |
{% endtab %}

{% tab title="float" %}
`ui.find_menu_float(item_name: string):` <mark style="color:purple;">`MenuItem`</mark>

| Name           | Type         | Description |
| -------------- | ------------ | ----------- |
| **item\_name** | **`string`** | -           |
{% endtab %}

{% tab title="bool" %}
`ui.find_menu_bool(item_name: string):` <mark style="color:purple;">`MenuItem`</mark>

| Name           | Type         | Description |
| -------------- | ------------ | ----------- |
| **item\_name** | **`string`** | -           |
{% endtab %}

{% tab title="color" %}
`ui.find_menu_color(item_name: string):` <mark style="color:purple;">`MenuItem`</mark>

| Name           | Type         | Description |
| -------------- | ------------ | ----------- |
| **item\_name** | **`string`** | -           |
{% endtab %}
{% endtabs %}

```lua
--> Example
local fake_lag_limit = ui.find_menu_int("Antiaim.fake_lag_limit")

fake_lag_limit:set(10)

cheat.notify(fake_lag_limit:get())
```

Returns the <mark style="color:purple;">`MenuItem`</mark> object that corresponds to the specified name.
