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

# ComboBox

Updated for version 3.37.

**It's recommended to first read about the base item before reading about other items** <https://luffyyy.gitbook.io/beardlib/menuui/menuui-item>

## ComboBox

### Creation

```lua
MyRandomMenu:ComboBox({
    name = "MyComboBox",
    text = "MANY ITEMS",
    items = {"OOO", {text = "Boop", on_callback = function() log("Booped") end}},
    value = 1,
    on_callback = function(item)
        log("Selected item", tostring(item:SelectedItem()))
        log("Index", tostring(item:Value()))
    end
})
MyRandomMenu:ComboBox({
    name = "MyComboBox2",
    text = "ITEMS",
    items = {"OOO", "Simple", "Yes"},
    value = 1,
    on_callback = function(item)
        log("Selected item", tostring(item:SelectedItem()))
        log("Index", tostring(item:Value()))
    end
})
```

### Parameters

| Parameter        | Type    | Description                                                                                                                                                                                                                                                                                                    |
| ---------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| items            | Table   | The items of the ComboBox, can be like: `{"First", "Second", "Third"}` `{{name = "First" whatever="yes"}, "Second", {name = "Third" whatever="lol"}}` They can even have their own callback: `{{name = "Item with a callback", on_callback = ClassClbk(self, "clbk")}}` Note: The original callback still runs |
| value            | Any     | Index/Key of the selected item, if free\_typing is enabled can be a string                                                                                                                                                                                                                                     |
| free\_typing     | Boolean | Should the combobox act as a textbox? This means the values will save even if it's not inside the items, calling Item:Value() or item.value will not always return an index                                                                                                                                    |
| items\_uppercase | Boolean | Makes all items' text capitalized                                                                                                                                                                                                                                                                              |
| items\_lowercase | Boolean | Makes all items' text non-capitalized                                                                                                                                                                                                                                                                          |

### Functions

#### Get

| Function       | Return Type | Description                                                                          |
| -------------- | ----------- | ------------------------------------------------------------------------------------ |
| Value()        | Any         | Returns the index/key of the selected item                                           |
| SelectedItem() | Any         | Returns the currently selected items or if free\_typing is enabled the value written |

#### Set

| Function                                                                   | Description                                                                                                                                                                                                                                                        |
| -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| SetItems(Table items)                                                      | Sets the items of the ComboBox, items being the new items                                                                                                                                                                                                          |
| SetValue(Number value, Boolean run\_callback, Boolean no\_items\_clbk)     | Sets the value of the item. `value` is mostly the index of the selected item but can be a string if free\_typing is enabled, `run_callback` determines if any callback should be called and `no_items_clbk` will disable individual callbacks for items if enabled |
| SetSelectedItem(Some item, Boolean run\_callback, Boolean no\_items\_clbk) | Sets the selected item or if free\_typing is enabled sets the value. Note: `item` has to be the exact value of what you want to select, if it's a table then you need to give this function the table                                                              |

#### Other

| Function          | Description                        |
| ----------------- | ---------------------------------- |
| Clear()           | Clears all items                   |
| Append(Any item)  | Appends an item to the items list  |
| Prepend(Any item) | Prepends an item to the items list |
| RefreshList()     | Refreshes the list                 |


---

# 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://luffyyy.gitbook.io/beardlib/menuui/menuui-combobox.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.
