vMenu Docs
API ReferenceMenu Items

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.

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

MenuItem item = new MenuItem("Disabled Item Text", "An item description, that supports ~r~color codes~s~.");

// Disable the item
item.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

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

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

ConstructorDescription
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

PropertyTypeDefault valueDescription
Textstring-Text on the left side of the item.
DescriptionstringnullShown below the menu while the item is highlighted.
LabelstringnullText on the right side of the item.¹
LeftIconIconIcon.NONEIcon on the left side of the item.¹
RightIconIconIcon.NONEIcon on the right side of the item.¹
EnabledbooltrueWhen false, the item is greyed out and cannot be used.
Indexint-1Read only. Position of the item in its menu, or -1 when it is not in a menu.
SelectedboolfalseRead only. Whether the item is highlighted. Always false when it is not in a menu.
ParentMenuMenunullThe menu holding this item. Mainly used internally.
ItemDatadynamicnullYour own data, see Attaching your own data.

Footnotes

¹ Not available on every item type. Each type's page lists what it does not support.


Methods

MenuItem has no methods. Act on an item through its menu:

I want to…Use
Press an item from codeMenu.SelectItem()
Remove an itemMenu.RemoveMenuItem()
Highlight an itemMenu.RefreshIndex()
Bind a submenu to an itemMenuController.BindMenuItem()

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

Item text, labels and descriptions support the game's formatting codes.

CodeEffect
~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."
);

Icons

MenuItem.Icon lists every icon (sprite) an item can show. Use it as MenuItem.Icon.LOCK.

IndexIcon nameExample
0Icon.NONEn/a
1Icon.LOCKIcon
2Icon.STARIcon
3Icon.WARNINGIcon
4Icon.CROWNIcon
5Icon.MEDAL_BRONZEIcon
6Icon.MEDAL_GOLDIcon
7Icon.MEDAL_SILVERIcon
8Icon.CASHIcon
9Icon.COKEIcon
10Icon.HEROINIcon
11Icon.METHIcon
12Icon.WEEDIcon
13Icon.AMMOIcon
14Icon.ARMORIcon
15Icon.BARBERIcon
16Icon.CLOTHINGIcon
17Icon.FRANKLINIcon
18Icon.BIKEIcon
19Icon.CARIcon
20Icon.GUNIcon
21Icon.HEALTH_HEARTIcon
22Icon.MAKEUP_BRUSHIcon
23Icon.MASKIcon
24Icon.MICHAELIcon
25Icon.TATTOOIcon
26Icon.TICKIcon
27Icon.TREVORIcon
28Icon.FEMALEIcon
29Icon.MALEIcon
30Icon.LOCK_ARENAIcon
31Icon.ADVERSARYIcon
32Icon.BASE_JUMPINGIcon
33Icon.BRIEFCASEIcon
34Icon.MISSION_STARIcon
35Icon.DEATHMATCHIcon
36Icon.CASTLEIcon
37Icon.TROPHYIcon
38Icon.RACE_FLAGIcon
39Icon.RACE_FLAG_PLANEIcon
40Icon.RACE_FLAG_BICYCLEIcon
41Icon.RACE_FLAG_PERSONIcon
42Icon.RACE_FLAG_CARIcon
43Icon.RACE_FLAG_BOAT_ANCHORIcon
44Icon.ROCKSTARIcon
45Icon.STUNTIcon
46Icon.STUNT_PREMIUMIcon
47Icon.RACE_FLAG_STUNT_JUMPIcon
48Icon.SHIELDIcon
49Icon.TEAM_DEATHMATCHIcon
50Icon.VEHICLE_DEATHMATCHIcon
51Icon.MP_AMMO_PICKUPIcon
52Icon.MP_AMMOIcon
53Icon.MP_CASHIcon
54Icon.MP_RPIcon
55Icon.MP_SPECTATINGIcon
56Icon.SALEIcon
57Icon.GLOBE_WHITEIcon
58Icon.GLOBE_REDIcon
59Icon.GLOBE_BLUEIcon
60Icon.GLOBE_YELLOWIcon
61Icon.GLOBE_GREENIcon
62Icon.GLOBE_ORANGEIcon
63Icon.INV_ARM_WRESTLINGIcon
64Icon.INV_BASEJUMPIcon
65Icon.INV_MISSIONIcon
66Icon.INV_DARTSIcon
67Icon.INV_DEATHMATCHIcon
68Icon.INV_DRUGIcon
69Icon.INV_CASTLEIcon
70Icon.INV_GOLFIcon
71Icon.INV_BIKEIcon
72Icon.INV_BOATIcon
73Icon.INV_ANCHORIcon
74Icon.INV_CARIcon
75Icon.INV_DOLLARIcon
76Icon.INV_COKEIcon
77Icon.INV_KEYIcon
78Icon.INV_DATAIcon
79Icon.INV_HELIIcon
80Icon.INV_HEORINIcon
81Icon.INV_KEYCARDIcon
82Icon.INV_METHIcon
83Icon.INV_BRIEFCASEIcon
84Icon.INV_LINKIcon
85Icon.INV_PERSONIcon
86Icon.INV_PLANEIcon
87Icon.INV_PLANE2Icon
88Icon.INV_QUESTIONMARKIcon
89Icon.INV_REMOTEIcon
90Icon.INV_SAFEIcon
91Icon.INV_STEER_WHEELIcon
92Icon.INV_WEAPONIcon
93Icon.INV_WEEDIcon
94Icon.INV_RACE_FLAG_PLANEIcon
95Icon.INV_RACE_FLAG_BICYCLEIcon
96Icon.INV_RACE_FLAG_BOAT_ANCHORIcon
97Icon.INV_RACE_FLAG_PERSONIcon
98Icon.INV_RACE_FLAG_CARIcon
99Icon.INV_RACE_FLAG_HELMETIcon
100Icon.INV_SHOOTING_RANGEIcon
101Icon.INV_SURVIVALIcon
102Icon.INV_TEAM_DEATHMATCHIcon
103Icon.INV_TENNISIcon
104Icon.INV_VEHICLE_DEATHMATCHIcon
105Icon.AUDIO_MUTEIcon
106Icon.AUDIO_INACTIVEIcon
107Icon.AUDIO_VOL1Icon
108Icon.AUDIO_VOL2Icon
109Icon.AUDIO_VOL3Icon
110Icon.COUNTRY_USAIcon
111Icon.COUNTRY_UKIcon
112Icon.COUNTRY_SWEDENIcon
113Icon.COUNTRY_KOREAIcon
114Icon.COUNTRY_JAPANIcon
115Icon.COUNTRY_ITALYIcon
116Icon.COUNTRY_GERMANYIcon
117Icon.COUNTRY_FRANCEIcon
118Icon.BRAND_ALBANYIcon
119Icon.BRAND_ANNISIcon
120Icon.BRAND_BANSHEEIcon
121Icon.BRAND_BENEFACTORIcon
122Icon.BRAND_BFIcon
123Icon.BRAND_BOLLOKANIcon
124Icon.BRAND_BRAVADOIcon
125Icon.BRAND_BRUTEIcon
126Icon.BRAND_BUCKINGHAMIcon
127Icon.BRAND_CANISIcon
128Icon.BRAND_CHARIOTIcon
129Icon.BRAND_CHEVALIcon
130Icon.BRAND_CLASSIQUEIcon
131Icon.BRAND_COILIcon
132Icon.BRAND_DECLASSEIcon
133Icon.BRAND_DEWBAUCHEEIcon
134Icon.BRAND_DILETTANTEIcon
135Icon.BRAND_DINKAIcon
136Icon.BRAND_DUNDREARYIcon
137Icon.BRAND_EMPORERIcon
138Icon.BRAND_ENUSIcon
139Icon.BRAND_FATHOMIcon
140Icon.BRAND_GALIVANTERIcon
141Icon.BRAND_GROTTIIcon
142Icon.BRAND_GROTTI2Icon
143Icon.BRAND_HIJAKIcon
144Icon.BRAND_HVYIcon
145Icon.BRAND_IMPONTEIcon
146Icon.BRAND_INVETEROIcon
147Icon.BRAND_JACKSHEEPEIcon
148Icon.BRAND_LCCIcon
149Icon.BRAND_JOBUILTIcon
150Icon.BRAND_KARINIcon
151Icon.BRAND_LAMPADATIIcon
152Icon.BRAND_MAIBATSUIcon
153Icon.BRAND_MAMMOTHIcon
154Icon.BRAND_MTLIcon
155Icon.BRAND_NAGASAKIIcon
156Icon.BRAND_OBEYIcon
157Icon.BRAND_OCELOTIcon
158Icon.BRAND_OVERFLODIcon
159Icon.BRAND_PEDIcon
160Icon.BRAND_PEGASSIIcon
161Icon.BRAND_PFISTERIcon
162Icon.BRAND_PRINCIPEIcon
163Icon.BRAND_PROGENIcon
164Icon.BRAND_PROGEN2Icon
165Icon.BRAND_RUNEIcon
166Icon.BRAND_SCHYSTERIcon
167Icon.BRAND_SHITZUIcon
168Icon.BRAND_SPEEDOPHILEIcon
169Icon.BRAND_STANLEYIcon
170Icon.BRAND_TRUFFADEIcon
171Icon.BRAND_UBERMACHTIcon
172Icon.BRAND_VAPIDIcon
173Icon.BRAND_VULCARIcon
174Icon.BRAND_WEENYIcon
175Icon.BRAND_WESTERNIcon
176Icon.BRAND_WESTERNMOTORCYCLEIcon
177Icon.BRAND_WILLARDIcon
178Icon.BRAND_ZIRCONIUMIcon
179Icon.INFOIcon

On this page