MenuItem
MenuItem
Section titled “MenuItem”A plain button. Every other item type inherits it, so the properties on this page apply to all of them. A MenuItem is also how you 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 = MenuItem.Icon.LOCK;
// Add a menu item to a menu:menu.AddMenuItem(item);The same with an object initializer:
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 the item raises OnItemSelect 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”| Constructor | Description |
|---|---|
MenuItem(string text) |
Creates an item without a description. |
MenuItem(string text, string description) |
Creates an item with a description, shown below the menu while the item is highlighted. Pass null for none. |
text is drawn on the left side of the row.
Properties
Section titled “Properties”| Property | Type | Default value | Description |
|---|---|---|---|
| Text | string | - | Text on the left side of the item. |
| Description | string | null | Shown below the menu while the item is highlighted. |
| Label | string | null | Text on the right side of the item.¹ |
| LeftIcon | Icon | Icon.NONE | Icon on the left side of the item.¹ |
| RightIcon | Icon | Icon.NONE | Icon on the right side of the item.¹ |
| Enabled | bool | true | When false, the item is greyed out and cannot be used. |
| Index | int | -1 | Read only. Position of the item in its menu, or -1 when it is not in a menu. |
| Selected | bool | false | Read only. Whether the item is highlighted. Always false when it is not in a menu. |
| ParentMenu | Menu | null | The menu holding this item. Mainly used internally. |
| ItemData | dynamic | null | Your own data, see Attaching your own data. |
Footnotes
Section titled “Footnotes”¹ Not available on every item type. Each type’s page lists what it does not support.
Methods
Section titled “Methods”MenuItem has no methods. Act on an item through its menu:
| 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 holds anything you want to identify the item by, so you do not have to encode it in the text or description. Useful for menus 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); }};It is dynamic, so anonymous objects work too:
// 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 support the game’s 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.");MenuItem.Icon lists every icon (sprite) an item can show. Use it as MenuItem.Icon.LOCK.
| Index | Icon name | Example |
|---|---|---|
| 0 | Icon.NONE | n/a |
| 1 | Icon.LOCK | ![]() |
| 2 | Icon.STAR | ![]() |
| 3 | Icon.WARNING | ![]() |
| 4 | Icon.CROWN | ![]() |
| 5 | Icon.MEDAL_BRONZE | ![]() |
| 6 | Icon.MEDAL_GOLD | ![]() |
| 7 | Icon.MEDAL_SILVER | ![]() |
| 8 | Icon.CASH | ![]() |
| 9 | Icon.COKE | ![]() |
| 10 | Icon.HEROIN | ![]() |
| 11 | Icon.METH | ![]() |
| 12 | Icon.WEED | ![]() |
| 13 | Icon.AMMO | ![]() |
| 14 | Icon.ARMOR | ![]() |
| 15 | Icon.BARBER | ![]() |
| 16 | Icon.CLOTHING | ![]() |
| 17 | Icon.FRANKLIN | ![]() |
| 18 | Icon.BIKE | ![]() |
| 19 | Icon.CAR | ![]() |
| 20 | Icon.GUN | ![]() |
| 21 | Icon.HEALTH_HEART | ![]() |
| 22 | Icon.MAKEUP_BRUSH | ![]() |
| 23 | Icon.MASK | ![]() |
| 24 | Icon.MICHAEL | ![]() |
| 25 | Icon.TATTOO | ![]() |
| 26 | Icon.TICK | ![]() |
| 27 | Icon.TREVOR | ![]() |
| 28 | Icon.FEMALE | ![]() |
| 29 | Icon.MALE | ![]() |
| 30 | Icon.LOCK_ARENA | ![]() |
| 31 | Icon.ADVERSARY | ![]() |
| 32 | Icon.BASE_JUMPING | ![]() |
| 33 | Icon.BRIEFCASE | ![]() |
| 34 | Icon.MISSION_STAR | ![]() |
| 35 | Icon.DEATHMATCH | ![]() |
| 36 | Icon.CASTLE | ![]() |
| 37 | Icon.TROPHY | ![]() |
| 38 | Icon.RACE_FLAG | ![]() |
| 39 | Icon.RACE_FLAG_PLANE | ![]() |
| 40 | Icon.RACE_FLAG_BICYCLE | ![]() |
| 41 | Icon.RACE_FLAG_PERSON | ![]() |
| 42 | Icon.RACE_FLAG_CAR | ![]() |
| 43 | Icon.RACE_FLAG_BOAT_ANCHOR | ![]() |
| 44 | Icon.ROCKSTAR | ![]() |
| 45 | Icon.STUNT | ![]() |
| 46 | Icon.STUNT_PREMIUM | ![]() |
| 47 | Icon.RACE_FLAG_STUNT_JUMP | ![]() |
| 48 | Icon.SHIELD | ![]() |
| 49 | Icon.TEAM_DEATHMATCH | ![]() |
| 50 | Icon.VEHICLE_DEATHMATCH | ![]() |
| 51 | Icon.MP_AMMO_PICKUP | ![]() |
| 52 | Icon.MP_AMMO | ![]() |
| 53 | Icon.MP_CASH | ![]() |
| 54 | Icon.MP_RP | ![]() |
| 55 | Icon.MP_SPECTATING | ![]() |
| 56 | Icon.SALE | ![]() |
| 57 | Icon.GLOBE_WHITE | ![]() |
| 58 | Icon.GLOBE_RED | ![]() |
| 59 | Icon.GLOBE_BLUE | ![]() |
| 60 | Icon.GLOBE_YELLOW | ![]() |
| 61 | Icon.GLOBE_GREEN | ![]() |
| 62 | Icon.GLOBE_ORANGE | ![]() |
| 63 | Icon.INV_ARM_WRESTLING | ![]() |
| 64 | Icon.INV_BASEJUMP | ![]() |
| 65 | Icon.INV_MISSION | ![]() |
| 66 | Icon.INV_DARTS | ![]() |
| 67 | Icon.INV_DEATHMATCH | ![]() |
| 68 | Icon.INV_DRUG | ![]() |
| 69 | Icon.INV_CASTLE | ![]() |
| 70 | Icon.INV_GOLF | ![]() |
| 71 | Icon.INV_BIKE | ![]() |
| 72 | Icon.INV_BOAT | ![]() |
| 73 | Icon.INV_ANCHOR | ![]() |
| 74 | Icon.INV_CAR | ![]() |
| 75 | Icon.INV_DOLLAR | ![]() |
| 76 | Icon.INV_COKE | ![]() |
| 77 | Icon.INV_KEY | ![]() |
| 78 | Icon.INV_DATA | ![]() |
| 79 | Icon.INV_HELI | ![]() |
| 80 | Icon.INV_HEORIN | ![]() |
| 81 | Icon.INV_KEYCARD | ![]() |
| 82 | Icon.INV_METH | ![]() |
| 83 | Icon.INV_BRIEFCASE | ![]() |
| 84 | Icon.INV_LINK | ![]() |
| 85 | Icon.INV_PERSON | ![]() |
| 86 | Icon.INV_PLANE | ![]() |
| 87 | Icon.INV_PLANE2 | ![]() |
| 88 | Icon.INV_QUESTIONMARK | ![]() |
| 89 | Icon.INV_REMOTE | ![]() |
| 90 | Icon.INV_SAFE | ![]() |
| 91 | Icon.INV_STEER_WHEEL | ![]() |
| 92 | Icon.INV_WEAPON | ![]() |
| 93 | Icon.INV_WEED | ![]() |
| 94 | Icon.INV_RACE_FLAG_PLANE | ![]() |
| 95 | Icon.INV_RACE_FLAG_BICYCLE | ![]() |
| 96 | Icon.INV_RACE_FLAG_BOAT_ANCHOR | ![]() |
| 97 | Icon.INV_RACE_FLAG_PERSON | ![]() |
| 98 | Icon.INV_RACE_FLAG_CAR | ![]() |
| 99 | Icon.INV_RACE_FLAG_HELMET | ![]() |
| 100 | Icon.INV_SHOOTING_RANGE | ![]() |
| 101 | Icon.INV_SURVIVAL | ![]() |
| 102 | Icon.INV_TEAM_DEATHMATCH | ![]() |
| 103 | Icon.INV_TENNIS | ![]() |
| 104 | Icon.INV_VEHICLE_DEATHMATCH | ![]() |
| 105 | Icon.AUDIO_MUTE | ![]() |
| 106 | Icon.AUDIO_INACTIVE | ![]() |
| 107 | Icon.AUDIO_VOL1 | ![]() |
| 108 | Icon.AUDIO_VOL2 | ![]() |
| 109 | Icon.AUDIO_VOL3 | ![]() |
| 110 | Icon.COUNTRY_USA | ![]() |
| 111 | Icon.COUNTRY_UK | ![]() |
| 112 | Icon.COUNTRY_SWEDEN | ![]() |
| 113 | Icon.COUNTRY_KOREA | ![]() |
| 114 | Icon.COUNTRY_JAPAN | ![]() |
| 115 | Icon.COUNTRY_ITALY | ![]() |
| 116 | Icon.COUNTRY_GERMANY | ![]() |
| 117 | Icon.COUNTRY_FRANCE | ![]() |
| 118 | Icon.BRAND_ALBANY | ![]() |
| 119 | Icon.BRAND_ANNIS | ![]() |
| 120 | Icon.BRAND_BANSHEE | ![]() |
| 121 | Icon.BRAND_BENEFACTOR | ![]() |
| 122 | Icon.BRAND_BF | ![]() |
| 123 | Icon.BRAND_BOLLOKAN | ![]() |
| 124 | Icon.BRAND_BRAVADO | ![]() |
| 125 | Icon.BRAND_BRUTE | ![]() |
| 126 | Icon.BRAND_BUCKINGHAM | ![]() |
| 127 | Icon.BRAND_CANIS | ![]() |
| 128 | Icon.BRAND_CHARIOT | ![]() |
| 129 | Icon.BRAND_CHEVAL | ![]() |
| 130 | Icon.BRAND_CLASSIQUE | ![]() |
| 131 | Icon.BRAND_COIL | ![]() |
| 132 | Icon.BRAND_DECLASSE | ![]() |
| 133 | Icon.BRAND_DEWBAUCHEE | ![]() |
| 134 | Icon.BRAND_DILETTANTE | ![]() |
| 135 | Icon.BRAND_DINKA | ![]() |
| 136 | Icon.BRAND_DUNDREARY | ![]() |
| 137 | Icon.BRAND_EMPORER | ![]() |
| 138 | Icon.BRAND_ENUS | ![]() |
| 139 | Icon.BRAND_FATHOM | ![]() |
| 140 | Icon.BRAND_GALIVANTER | ![]() |
| 141 | Icon.BRAND_GROTTI | ![]() |
| 142 | Icon.BRAND_GROTTI2 | ![]() |
| 143 | Icon.BRAND_HIJAK | ![]() |
| 144 | Icon.BRAND_HVY | ![]() |
| 145 | Icon.BRAND_IMPONTE | ![]() |
| 146 | Icon.BRAND_INVETERO | ![]() |
| 147 | Icon.BRAND_JACKSHEEPE | ![]() |
| 148 | Icon.BRAND_LCC | ![]() |
| 149 | Icon.BRAND_JOBUILT | ![]() |
| 150 | Icon.BRAND_KARIN | ![]() |
| 151 | Icon.BRAND_LAMPADATI | ![]() |
| 152 | Icon.BRAND_MAIBATSU | ![]() |
| 153 | Icon.BRAND_MAMMOTH | ![]() |
| 154 | Icon.BRAND_MTL | ![]() |
| 155 | Icon.BRAND_NAGASAKI | ![]() |
| 156 | Icon.BRAND_OBEY | ![]() |
| 157 | Icon.BRAND_OCELOT | ![]() |
| 158 | Icon.BRAND_OVERFLOD | ![]() |
| 159 | Icon.BRAND_PED | ![]() |
| 160 | Icon.BRAND_PEGASSI | ![]() |
| 161 | Icon.BRAND_PFISTER | ![]() |
| 162 | Icon.BRAND_PRINCIPE | ![]() |
| 163 | Icon.BRAND_PROGEN | ![]() |
| 164 | Icon.BRAND_PROGEN2 | ![]() |
| 165 | Icon.BRAND_RUNE | ![]() |
| 166 | Icon.BRAND_SCHYSTER | ![]() |
| 167 | Icon.BRAND_SHITZU | ![]() |
| 168 | Icon.BRAND_SPEEDOPHILE | ![]() |
| 169 | Icon.BRAND_STANLEY | ![]() |
| 170 | Icon.BRAND_TRUFFADE | ![]() |
| 171 | Icon.BRAND_UBERMACHT | ![]() |
| 172 | Icon.BRAND_VAPID | ![]() |
| 173 | Icon.BRAND_VULCAR | ![]() |
| 174 | Icon.BRAND_WEENY | ![]() |
| 175 | Icon.BRAND_WESTERN | ![]() |
| 176 | Icon.BRAND_WESTERNMOTORCYCLE | ![]() |
| 177 | Icon.BRAND_WILLARD | ![]() |
| 178 | Icon.BRAND_ZIRCONIUM | ![]() |
| 179 | Icon.INFO | ![]() |


















































































































































































