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

# Menus

Built-in, configurable menu that uses keyboard inputs.

## Methods

### `CreateMenu(entries, title, closeCB)`

Creates and returns `menu` object.

* entries<mark style="color:red;">\*</mark> (table) - Table of menu entries (see [below](#menu-entries-table) for structure)
* title (string) - Visible title of the menu
* closeCB (function) - Function which is called once the menu is closed

<mark style="color:red;">\*</mark> = required arguments

Example:

<pre class="language-lua"><code class="lang-lua"><strong>local menu = FOM.CreateMenu({
</strong>    { {text = "Option 1"}, {text = "Option 2"} },
    { {text = "Print something", func = function() print("something") end} }
}, "Example Menu", function()
    print("This example menu was closed")
end)

menu.open()
</code></pre>

### `menu.open()`

Opens a previously created menu. Takes no parameters.

### `menu.close()`

Closes a previously created menu. Takes no parameters.

### `menu.visible(text, visible)`

Changes the visibility of one menu line that matches the specified `text`

* text<mark style="color:red;">\*</mark> (string) - The text of the menu line to change visibility of
* visible<mark style="color:red;">\*</mark> (boolean) - The visibility of the text

<mark style="color:red;">\*</mark> = required argument

## Data Types

### Menu Entries Table

The whole table represents the whole menu with each entry in the table being a new line in the in-game menu.

Each entry in the `Menu Entries Table` list represents an option in the table. Each option can be navigated using the left and right arrow keys. Each entry is an entry which has the following keys:

* text<mark style="color:red;">\*</mark> (string)
* func (function)

<mark style="color:red;">\*</mark> = required entry

See example use of `Menu Entries Table` above under the [`CreateMenu` ](#createmenu-entries-title-closecb)method.

Reference: `utils/cl_menu.lua`
