Skip to content

API Reference

A full reference of every public class, property, method and event in MenuAPI.

If you have not set up MenuAPI yet, start at Setup.


Class What it is
Menu A single menu: a banner, a subtitle, a list of items and a description box. This is also where all events live.
MenuController The static controller that draws your menus and handles all controls. You register your menus here.
Menu Items Everything you can put inside a menu: buttons, checkboxes, lists, dynamic lists and sliders.
Events Every event a menu can raise, with the parameters they pass to your handler.

This is a complete, working menu. Everything else in this reference builds on these few calls.

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 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
Open, close or navigate a menu from code Menu
Create a submenu MenuController.BindMenuItem()
Change the menu toggle key, or open menus myself MenuController
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.InstructionalButtons
Run my own code when a control is pressed Menu.ButtonPressHandlers
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