Skip to content

API Reference

Every public class, property, method and event in MenuAPI. Not set up yet? Start at Setup.


Class What it is
Menu A single menu: banner, subtitle, items and description box. Also where all events live.
MenuController The static controller that registers, draws and controls your menus.
Pagination Splitting a long menu into pages, moved between with left and right.
Menu Items Buttons, checkboxes, lists, dynamic lists and sliders.
Events Every event a menu can raise, with its parameters.
MenuTicks A read only view of the loops MenuAPI runs, and when each one stops.

Examples in this reference use Legacy names (BaseScript, Debug.WriteLine). Setup shows the Enhanced equivalents.

using System.Collections.Generic;
using CitizenFX.Core;
using MenuAPI;
namespace MyResource
{
public class MyMenu : BaseScript
{
public MyMenu()
{
// 1. Create a menu and register it with the controller.
Menu menu = new Menu("My Resource", "Main Menu");
MenuController.AddMenu(menu);
// 2. Add some items.
MenuItem button = new MenuItem("A button", "Press enter on me.");
MenuCheckboxItem checkbox = new MenuCheckboxItem("A checkbox", "Toggle me.", false);
MenuListItem list = new MenuListItem("A list", new List<string>() { "One", "Two", "Three" }, 0);
menu.AddMenuItem(button);
menu.AddMenuItem(checkbox);
menu.AddMenuItem(list);
// 3. React to what the user does.
menu.OnItemSelect += (_menu, _item, _index) =>
{
if (_item == button)
{
Debug.WriteLine("The button was pressed!");
}
};
menu.OnCheckboxChange += (_menu, _item, _index, _checked) =>
{
Debug.WriteLine($"The checkbox is now {_checked}.");
};
// 4. Open it. (The menu toggle key, M by default, already opens the
// first registered menu for you, so this is only needed if you
// want your own trigger.)
menu.OpenMenu();
}
}
}

I want to… See
Create a menu, add or remove items, sort or filter them Menu
Show hundreds or thousands of items without endless scrolling Pagination
Open, close or navigate a menu from code Menu
Create a submenu MenuController.BindMenuItem()
Know which keys open and control the menu, and how players rebind them Key bindings
Open menus myself instead of using the toggle key Menu.OpenMenu()
Move menus to the right side of the screen MenuController.MenuAlignment
Stop the user from closing a menu MenuController.PreventExitingMenu
Change the instructional buttons at the bottom of the screen Menu instructional buttons
Run my own code when a key is pressed Key bindings
Add an icon or right-hand text to an item MenuItem
Attach my own data to an item MenuItem.ItemData
Know which event fires for which item type Events
Show a weapon or vehicle stats panel Menu
See what MenuAPI is actually running, and when MenuTicks