MenuItem
MenuItem
Section titled “MenuItem”A plain button: the simplest menu item there is. All other menu items inherit the ‘regular’ MenuItem class, so every property on this page also applies to them.
A MenuItem is also what you use to open a submenu.
Example usage
Section titled “Example usage”MenuItem item = new MenuItem("Disabled Item Text", "An item description, that supports ~r~color codes~s~.");
// Disable the itemitem.Enabled = false;
// Set the left item icon to the 'lock' icon.item.LeftIcon = Icon.LOCK;
// Add a menu item to a menu:menu.AddMenuItem(item);Items are usually created with an object initializer, which keeps things a bit shorter:
menu.AddMenuItem(new MenuItem("Buy vehicle", "Costs $1000."){ Label = "$1000", LeftIcon = MenuItem.Icon.CAR, RightIcon = MenuItem.Icon.CASH});Reacting to a button press
Section titled “Reacting to a button press”Pressing a plain menu item raises the OnItemSelect event on its parent menu:
MenuItem button = new MenuItem("Fix vehicle", "Repairs the vehicle you're in.");menu.AddMenuItem(button);
menu.OnItemSelect += (_menu, _item, _index) =>{ if (_item == button) { SetVehicleFixed(GetVehiclePedIsIn(PlayerPedId(), false)); }};Using it as a submenu button
Section titled “Using it as a submenu button”Menu submenu = new Menu("Vehicle options");
MenuItem submenuButton = new MenuItem("Vehicle options", "Open the vehicle options."){ Label = "→→→"};menu.AddMenuItem(submenuButton);
MenuController.BindMenuItem(menu, submenu, submenuButton);Constructors
Section titled “Constructors”MenuItem(string text)
Section titled “MenuItem(string text)”Creates a new menu item without a description.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
| text | string | The text displayed on the left side of the item. |
MenuItem(string text, string description)
Section titled “MenuItem(string text, string description)”Creates a new menu item with a description, which is shown in the box below the menu while the item is highlighted.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
| text | string | The text displayed on the left side of the item. |
| description | string | The description shown below the menu while this item is selected. Pass null for no description. |
Properties
Section titled “Properties”| Property | Type | Default value | Description | Optional |
|---|---|---|---|---|
| Text | String | - | The text to display on the left side of the menu item | No |
| Description | String | Null | A description text which will be displayed below the menu, when this menu item is currently selected. | Yes |
| Label | String | Null | Text that is displayed on the right side of the item.¹ | Yes |
| LeftIcon | Icon | Icon.NONE | An Icon that will appear on the left side of the menu item.¹ | Yes |
| RightIcon | Icon | Icon.NONE | An Icon that will appear on the right side of the menu item.¹ | Yes |
| Enabled | boolean | true | If set to false, the menu item will be grayed out and can not be toggled on/off. | Yes |
| Index | int | -1 | (Getter only) Gets the position of this menu item in the current menu. Returns -1 if this menu item is not inside a menu. | Yes |
| Selected | boolean | false | (Getter only) Gets whether or not this menu item is currently highlighted (if the current menu index is the same as this menu item index). Returns false by default if this menu item is not in a menu. | Yes |
| ParentMenu | Menu | Null | This is mainly used internally to get and set this item’s parent menu. This is to avoid having to manually scan all menu’s for this menu item. | Yes |
| PositionOnScreen | int | 0 | (Getter only) Gets the current screen position of this item. | Yes |
| ItemData | dynamic | Null | Allows you to attach data to a menu item if you want to identify the menu item without having to put identification info in the visible text or description. | Yes |
Footnotes
Section titled “Footnotes”¹ Not available for all MenuItem types.
Methods
Section titled “Methods”There are no methods available for the standard MenuItem type.
Everything you would do to an item is done through its menu instead:
| I want to… | Use |
|---|---|
| Press an item from code | Menu.SelectItem() |
| Remove an item | Menu.RemoveMenuItem() |
| Highlight an item | Menu.RefreshIndex() |
| Bind a submenu to an item | MenuController.BindMenuItem() |
Attaching your own data
Section titled “Attaching your own data”ItemData is a dynamic property that lets you hang whatever you like on a menu item, so you do not have to encode identifying information in the visible text or description. This is the easiest way to handle menus that are built in a loop.
foreach (var vehicle in vehicles){ menu.AddMenuItem(new MenuItem(vehicle.DisplayName, $"Spawn a {vehicle.DisplayName}.") { ItemData = vehicle });}
menu.OnItemSelect += (_menu, _item, _index) =>{ if (_item.ItemData != null) { SpawnVehicle(_item.ItemData.Model); }};Because ItemData is dynamic, anything works: a string, an int, an anonymous object, or one of your own classes.
// An anonymous object.item.ItemData = new { category = "vehicles", price = 1000 };
// Then filter on it.menu.FilterMenuItems(i => i.ItemData?.category == "vehicles");Text formatting
Section titled “Text formatting”Item text, labels and descriptions all support the game’s text formatting codes.
| Code | Effect |
|---|---|
~r~ |
Red |
~b~ |
Blue |
~g~ |
Green |
~y~ |
Yellow |
~p~ |
Purple |
~o~ |
Orange |
~c~ |
Grey |
~w~ |
White |
~s~ |
Resets back to the default color |
~n~ |
New line |
~h~ |
Bold (toggles) |
MenuItem item = new MenuItem( "~b~Important~s~ button", "This description has a ~r~red~s~ word in it, and~n~a second line.");The Icon (enum) is a list of all icons (sprites) which can be used in MenuItems.
| Index | Icon name | Game | Example |
|---|---|---|---|
| 0 | Icon.NONE | Both | n/a |
| 1 | Icon.LOCK | FiveM | ![]() |
| 2 | Icon.STAR | FiveM | ![]() |
| 3 | Icon.WARNING | FiveM | ![]() |
| 4 | Icon.CROWN | FiveM | ![]() |
| 5 | Icon.MEDAL_BRONZE | FiveM | ![]() |
| 6 | Icon.MEDAL_GOLD | FiveM | ![]() |
| 7 | Icon.MEDAL_SILVER | FiveM | ![]() |
| 8 | Icon.CASH | FiveM | ![]() |
| 9 | Icon.COKE | FiveM | ![]() |
| 10 | Icon.HEROIN | FiveM | ![]() |
| 11 | Icon.METH | FiveM | ![]() |
| 12 | Icon.WEED | FiveM | ![]() |
| 13 | Icon.AMMO | FiveM | ![]() |
| 14 | Icon.ARMOR | FiveM | ![]() |
| 15 | Icon.BARBER | FiveM | ![]() |
| 16 | Icon.CLOTHING | FiveM | ![]() |
| 17 | Icon.FRANKLIN | FiveM | ![]() |
| 18 | Icon.BIKE | FiveM | ![]() |
| 19 | Icon.CAR | FiveM | ![]() |
| 20 | Icon.GUN | FiveM | ![]() |
| 21 | Icon.HEALTH_HEART | FiveM | ![]() |
| 22 | Icon.MAKEUP_BRUSH | FiveM | ![]() |
| 23 | Icon.MASK | FiveM | ![]() |
| 24 | Icon.MICHAEL | FiveM | ![]() |
| 25 | Icon.TATTOO | FiveM | ![]() |
| 26 | Icon.TICK | FiveM | ![]() |
| 27 | Icon.TREVOR | FiveM | ![]() |
| 28 | Icon.FEMALE | FiveM | ![]() |
| 29 | Icon.MALE | FiveM | ![]() |
| 30 | Icon.LOCK_ARENA | FiveM | ![]() |
| 31 | Icon.ADVERSARY | FiveM | ![]() |
| 32 | Icon.BASE_JUMPING | FiveM | ![]() |
| 33 | Icon.BRIEFCASE | FiveM | ![]() |
| 34 | Icon.MISSION_STAR | FiveM | ![]() |
| 35 | Icon.DEATHMATCH | FiveM | ![]() |
| 36 | Icon.CASTLE | FiveM | ![]() |
| 37 | Icon.TROPHY | FiveM | ![]() |
| 38 | Icon.RACE_FLAG | FiveM | ![]() |
| 39 | Icon.RACE_FLAG_PLANE | FiveM | ![]() |
| 40 | Icon.RACE_FLAG_BICYCLE | FiveM | ![]() |
| 41 | Icon.RACE_FLAG_PERSON | FiveM | ![]() |
| 42 | Icon.RACE_FLAG_CAR | FiveM | ![]() |
| 43 | Icon.RACE_FLAG_BOAT_ANCHOR | FiveM | ![]() |
| 44 | Icon.ROCKSTAR | FiveM | ![]() |
| 45 | Icon.STUNT | FiveM | ![]() |
| 46 | Icon.STUNT_PREMIUM | FiveM | ![]() |
| 47 | Icon.RACE_FLAG_STUNT_JUMP | FiveM | ![]() |
| 48 | Icon.SHIELD | FiveM | ![]() |
| 49 | Icon.TEAM_DEATHMATCH | FiveM | ![]() |
| 50 | Icon.VEHICLE_DEATHMATCH | FiveM | ![]() |
| 51 | Icon.MP_AMMO_PICKUP | FiveM | ![]() |
| 52 | Icon.MP_AMMO | FiveM | ![]() |
| 53 | Icon.MP_CASH | FiveM | ![]() |
| 54 | Icon.MP_RP | FiveM | ![]() |
| 55 | Icon.MP_SPECTATING | FiveM | ![]() |
| 56 | Icon.SALE | FiveM | ![]() |
| 57 | Icon.GLOBE_WHITE | FiveM | ![]() |
| 58 | Icon.GLOBE_RED | FiveM | ![]() |
| 59 | Icon.GLOBE_BLUE | FiveM | ![]() |
| 60 | Icon.GLOBE_YELLOW | FiveM | ![]() |
| 61 | Icon.GLOBE_GREEN | FiveM | ![]() |
| 62 | Icon.GLOBE_ORANGE | FiveM | ![]() |
| 63 | Icon.INV_ARM_WRESTLING | FiveM | ![]() |
| 64 | Icon.INV_BASEJUMP | FiveM | ![]() |
| 65 | Icon.INV_MISSION | FiveM | ![]() |
| 66 | Icon.INV_DARTS | FiveM | ![]() |
| 67 | Icon.INV_DEATHMATCH | FiveM | ![]() |
| 68 | Icon.INV_DRUG | FiveM | ![]() |
| 69 | Icon.INV_CASTLE | FiveM | ![]() |
| 70 | Icon.INV_GOLF | FiveM | ![]() |
| 71 | Icon.INV_BIKE | FiveM | ![]() |
| 72 | Icon.INV_BOAT | FiveM | ![]() |
| 73 | Icon.INV_ANCHOR | FiveM | ![]() |
| 74 | Icon.INV_CAR | FiveM | ![]() |
| 75 | Icon.INV_DOLLAR | FiveM | ![]() |
| 76 | Icon.INV_COKE | FiveM | ![]() |
| 77 | Icon.INV_KEY | FiveM | ![]() |
| 78 | Icon.INV_DATA | FiveM | ![]() |
| 79 | Icon.INV_HELI | FiveM | ![]() |
| 80 | Icon.INV_HEORIN | FiveM | ![]() |
| 81 | Icon.INV_KEYCARD | FiveM | ![]() |
| 82 | Icon.INV_METH | FiveM | ![]() |
| 83 | Icon.INV_BRIEFCASE | FiveM | ![]() |
| 84 | Icon.INV_LINK | FiveM | ![]() |
| 85 | Icon.INV_PERSON | FiveM | ![]() |
| 86 | Icon.INV_PLANE | FiveM | ![]() |
| 87 | Icon.INV_PLANE2 | FiveM | ![]() |
| 88 | Icon.INV_QUESTIONMARK | FiveM | ![]() |
| 89 | Icon.INV_REMOTE | FiveM | ![]() |
| 90 | Icon.INV_SAFE | FiveM | ![]() |
| 91 | Icon.INV_STEER_WHEEL | FiveM | ![]() |
| 92 | Icon.INV_WEAPON | FiveM | ![]() |
| 93 | Icon.INV_WEED | FiveM | ![]() |
| 94 | Icon.INV_RACE_FLAG_PLANE | FiveM | ![]() |
| 95 | Icon.INV_RACE_FLAG_BICYCLE | FiveM | ![]() |
| 96 | Icon.INV_RACE_FLAG_BOAT_ANCHOR | FiveM | ![]() |
| 97 | Icon.INV_RACE_FLAG_PERSON | FiveM | ![]() |
| 98 | Icon.INV_RACE_FLAG_CAR | FiveM | ![]() |
| 99 | Icon.INV_RACE_FLAG_HELMET | FiveM | ![]() |
| 100 | Icon.INV_SHOOTING_RANGE | FiveM | ![]() |
| 101 | Icon.INV_SURVIVAL | FiveM | ![]() |
| 102 | Icon.INV_TEAM_DEATHMATCH | FiveM | ![]() |
| 103 | Icon.INV_TENNIS | FiveM | ![]() |
| 104 | Icon.INV_VEHICLE_DEATHMATCH | FiveM | ![]() |
| 105 | Icon.AUDIO_MUTE | FiveM | ![]() |
| 106 | Icon.AUDIO_INACTIVE | FiveM | ![]() |
| 107 | Icon.AUDIO_VOL1 | FiveM | ![]() |
| 108 | Icon.AUDIO_VOL2 | FiveM | ![]() |
| 109 | Icon.AUDIO_VOL3 | FiveM | ![]() |
| 110 | Icon.COUNTRY_USA | FiveM | ![]() |
| 111 | Icon.COUNTRY_UK | FiveM | ![]() |
| 112 | Icon.COUNTRY_SWEDEN | FiveM | ![]() |
| 113 | Icon.COUNTRY_KOREA | FiveM | ![]() |
| 114 | Icon.COUNTRY_JAPAN | FiveM | ![]() |
| 115 | Icon.COUNTRY_ITALY | FiveM | ![]() |
| 116 | Icon.COUNTRY_GERMANY | FiveM | ![]() |
| 117 | Icon.COUNTRY_FRANCE | FiveM | ![]() |
| 118 | Icon.BRAND_ALBANY | FiveM | ![]() |
| 119 | Icon.BRAND_ANNIS | FiveM | ![]() |
| 120 | Icon.BRAND_BANSHEE | FiveM | ![]() |
| 121 | Icon.BRAND_BENEFACTOR | FiveM | ![]() |
| 122 | Icon.BRAND_BF | FiveM | ![]() |
| 123 | Icon.BRAND_BOLLOKAN | FiveM | ![]() |
| 124 | Icon.BRAND_BRAVADO | FiveM | ![]() |
| 125 | Icon.BRAND_BRUTE | FiveM | ![]() |
| 126 | Icon.BRAND_BUCKINGHAM | FiveM | ![]() |
| 127 | Icon.BRAND_CANIS | FiveM | ![]() |
| 128 | Icon.BRAND_CHARIOT | FiveM | ![]() |
| 129 | Icon.BRAND_CHEVAL | FiveM | ![]() |
| 130 | Icon.BRAND_CLASSIQUE | FiveM | ![]() |
| 131 | Icon.BRAND_COIL | FiveM | ![]() |
| 132 | Icon.BRAND_DECLASSE | FiveM | ![]() |
| 133 | Icon.BRAND_DEWBAUCHEE | FiveM | ![]() |
| 134 | Icon.BRAND_DILETTANTE | FiveM | ![]() |
| 135 | Icon.BRAND_DINKA | FiveM | ![]() |
| 136 | Icon.BRAND_DUNDREARY | FiveM | ![]() |
| 137 | Icon.BRAND_EMPORER | FiveM | ![]() |
| 138 | Icon.BRAND_ENUS | FiveM | ![]() |
| 139 | Icon.BRAND_FATHOM | FiveM | ![]() |
| 140 | Icon.BRAND_GALIVANTER | FiveM | ![]() |
| 141 | Icon.BRAND_GROTTI | FiveM | ![]() |
| 142 | Icon.BRAND_GROTTI2 | FiveM | ![]() |
| 143 | Icon.BRAND_HIJAK | FiveM | ![]() |
| 144 | Icon.BRAND_HVY | FiveM | ![]() |
| 145 | Icon.BRAND_IMPONTE | FiveM | ![]() |
| 146 | Icon.BRAND_INVETERO | FiveM | ![]() |
| 147 | Icon.BRAND_JACKSHEEPE | FiveM | ![]() |
| 148 | Icon.BRAND_LCC | FiveM | ![]() |
| 149 | Icon.BRAND_JOBUILT | FiveM | ![]() |
| 150 | Icon.BRAND_KARIN | FiveM | ![]() |
| 151 | Icon.BRAND_LAMPADATI | FiveM | ![]() |
| 152 | Icon.BRAND_MAIBATSU | FiveM | ![]() |
| 153 | Icon.BRAND_MAMMOTH | FiveM | ![]() |
| 154 | Icon.BRAND_MTL | FiveM | ![]() |
| 155 | Icon.BRAND_NAGASAKI | FiveM | ![]() |
| 156 | Icon.BRAND_OBEY | FiveM | ![]() |
| 157 | Icon.BRAND_OCELOT | FiveM | ![]() |
| 158 | Icon.BRAND_OVERFLOD | FiveM | ![]() |
| 159 | Icon.BRAND_PED | FiveM | ![]() |
| 160 | Icon.BRAND_PEGASSI | FiveM | ![]() |
| 161 | Icon.BRAND_PFISTER | FiveM | ![]() |
| 162 | Icon.BRAND_PRINCIPE | FiveM | ![]() |
| 163 | Icon.BRAND_PROGEN | FiveM | ![]() |
| 164 | Icon.BRAND_PROGEN2 | FiveM | ![]() |
| 165 | Icon.BRAND_RUNE | FiveM | ![]() |
| 166 | Icon.BRAND_SCHYSTER | FiveM | ![]() |
| 167 | Icon.BRAND_SHITZU | FiveM | ![]() |
| 168 | Icon.BRAND_SPEEDOPHILE | FiveM | ![]() |
| 169 | Icon.BRAND_STANLEY | FiveM | ![]() |
| 170 | Icon.BRAND_TRUFFADE | FiveM | ![]() |
| 171 | Icon.BRAND_UBERMACHT | FiveM | ![]() |
| 172 | Icon.BRAND_VAPID | FiveM | ![]() |
| 173 | Icon.BRAND_VULCAR | FiveM | ![]() |
| 174 | Icon.BRAND_WEENY | FiveM | ![]() |
| 175 | Icon.BRAND_WESTERN | FiveM | ![]() |
| 176 | Icon.BRAND_WESTERNMOTORCYCLE | FiveM | ![]() |
| 177 | Icon.BRAND_WILLARD | FiveM | ![]() |
| 178 | Icon.BRAND_ZIRCONIUM | FiveM | ![]() |
| 179 | Icon.INFO | FiveM | ![]() |
| 1 | Icon.LOCK | RedM | - |
| 2 | Icon.TICK | RedM | - |
| 3 | Icon.CIRCLE | RedM | - |
| 4 | Icon.SADDLE | RedM | - |
| 5 | Icon.STAR | RedM | - |
| 6 | Icon.ARROW_LEFT | RedM | - |
| 7 | Icon.ARROW_RIGHT | RedM | - |
| 8 | Icon.INVITE_SENT | RedM | - |
| 9 | Icon.SELECTION_BOX | RedM | - |


















































































































































































