| Version: 3.3.1

Public Member Functions | Static Public Member Functions | List of all members
wxMenuItem Class Reference
Class List by Category » Menus

`#include <wx/menuitem.h>`

Inheritance diagram for wxMenuItem:
[legend]

## Detailed Description

A menu item represents an item in a menu.

Note that you usually don't have to deal with it directly as wxMenu methods usually construct an object of this class for you.

## Events emitted by this class

The following event handler macros redirect the events to member function handlers 'func' with prototypes like:

void handlerFuncName(wxCommandEvent& event) or void handlerFuncName(wxMenuEvent& event)

Event macros for events emitted by this class:

- EVT_MENU(id, func):
  Process a `wxEVT_MENU` command, which is generated by a menu item. This type of event is sent as wxCommandEvent.
- EVT_MENU_RANGE(id1, id2, func):
  Process a `wxEVT_MENU` command, which is generated by a range of menu items. This type of event is sent as wxCommandEvent.
- EVT_MENU_OPEN(func):
  A menu is about to be opened. On Windows, this is only sent once for each navigation of the menubar (up until all menus have closed). This type of event is sent as wxMenuEvent.
- EVT_MENU_CLOSE(func):
  A menu has been just closed. This type of event is sent as wxMenuEvent.
- EVT_MENU_HIGHLIGHT(id, func):
  The menu item with the specified id has been highlighted. If the id is wxID_NONE, highlighting has been removed from the previously highlighted menu item and there is no highlighted item any more. This is used by wxFrame to show help prompts in the status bar. This type of event is sent as wxMenuEvent.
- EVT_MENU_HIGHLIGHT_ALL(func):
  A menu item has been highlighted, i.e. the currently selected menu item has changed. This type of event is sent as wxMenuEvent.

# Customizing Menu Items Appearance

This class provides several functions for customizing the menu items appearance that are available only in wxMSW port. These functions should not be used in portable programs and, moreover, have some known limitations even in wxMSW: using them switches the menu item in an "owner drawn" mode, where it is painted by wxWidgets itself and not the system, which may result in a slightly different appearance for it. Owner drawn items are also incompatible with dark mode support and using them makes the entire menu containing them to use standard light mode colours even in dark mode.

##

Library: wxCore
Category: Menus

See also
  wxMenuBar, wxMenu

## Getters
wxColour & | GetBackgroundColour () const
| Returns the background colour associated with the menu item. More...
wxBitmap | GetBitmap () const
| Returns the item bitmap. More...
wxBitmap | GetBitmap (bool checked) const
| Returns the checked or unchecked bitmap. More...
wxBitmapBundle | GetBitmapBundle () const
| Returns the bitmap bundle containing the bitmap used for this item. More...
virtual wxBitmap | GetDisabledBitmap () const
| Returns the bitmap used for disabled items. More...
wxFont & | GetFont () const
| Returns the font associated with the menu item. More...
const wxString & | GetHelp () const
| Returns the help string associated with the menu item. More...
int | GetId () const
| Returns the menu item identifier. More...
virtual wxString | GetItemLabel () const
| Returns the text associated with the menu item including any accelerator characters that were passed to the constructor or SetItemLabel(). More...
virtual wxString | GetItemLabelText () const
| Returns the text associated with the menu item, without any accelerator characters. More...
wxItemKind | GetKind () const
| Returns the item kind, one of `wxITEM_SEPARATOR`, `wxITEM_NORMAL`, `wxITEM_CHECK` or `wxITEM_RADIO`. More...
wxString | GetLabel () const
| Returns the text associated with the menu item without any accelerator characters it might contain. More...
int | GetMarginWidth () const
| Gets the width of the menu item checkmark bitmap. More...
wxMenu * | GetMenu () const
| Returns the menu this menu item is in, or nullptr if this menu item is not attached. More...
wxString | GetName () const
| Returns the text associated with the menu item. More...
wxMenu * | GetSubMenu () const
| Returns the submenu associated with the menu item, or nullptr if there isn't one. More...
const wxString & | GetText () const
| Returns the text associated with the menu item, such as it was passed to the wxMenuItem constructor, i.e. with any accelerator characters it may contain. More...
wxColour & | GetTextColour () const
| Returns the text colour associated with the menu item. More...
virtual wxAcceleratorEntry * | GetAccel () const
| Get our accelerator or nullptr (caller must delete the pointer) More...
static wxAcceleratorEntry * | GetAccelFromString (const wxString &label)
| Extract the accelerator from the given menu string, return nullptr if none found. More...

## Public Member Functions
| wxMenuItem (wxMenu *parentMenu=nullptr, int id=wxID_SEPARATOR, const wxString &text=wxEmptyString, const wxString &helpString=wxEmptyString, wxItemKind kind=wxITEM_NORMAL, wxMenu *subMenu=nullptr)
| Constructs a wxMenuItem object. More...
virtual | ~wxMenuItem ()
| Destructor. More...
virtual void | Check (bool check=true)
| Checks or unchecks the menu item. More...
virtual void | Enable (bool enable=true)
| Enables or disables the menu item. More...
Checkers
bool | IsCheck () const
| Returns true if the item is a check item. More...
bool | IsCheckable () const
| Returns true if the item is checkable. More...
virtual bool | IsChecked () const
| Returns true if the item is checked. More...
virtual bool | IsEnabled () const
| Returns true if the item is enabled. More...
bool | IsRadio () const
| Returns true if the item is a radio button. More...
bool | IsSeparator () const
| Returns true if the item is a separator. More...
bool | IsSubMenu () const
| Returns true if the item is a submenu. More...
Setters
void | SetBackgroundColour (const wxColour &colour)
| Sets the background colour associated with the menu item. More...
void | SetBitmap (const wxBitmapBundle &bmp)
| Sets the bitmap for the menu item. More...
void | SetBitmap (const wxBitmapBundle &bmp, bool checked)
| Sets the checked or unchecked bitmap for the menu item. More...
void | SetBitmaps (const wxBitmapBundle &checked, const wxBitmapBundle &unchecked=wxNullBitmap)
| Sets the checked/unchecked bitmaps for the menu item. More...
void | SetDisabledBitmap (const wxBitmapBundle &disabled)
| Sets the to be used for disabled menu items. More...
void | SetFont (const wxFont &font)
| Sets the font associated with the menu item. More...
void | SetHelp (const wxString &helpString)
| Sets the help string. More...
virtual void | SetItemLabel (const wxString &label)
| Sets the label associated with the menu item. More...
void | SetMarginWidth (int width)
| Sets the width of the menu item checkmark bitmap. More...
void | SetMenu (wxMenu *menu)
| Sets the parent menu which will contain this menu item. More...
void | SetSubMenu (wxMenu *menu)
| Sets the submenu of this menu item. More...
virtual void | SetText (const wxString &text)
| Sets the text associated with the menu item. More...
void | SetTextColour (const wxColour &colour)
| Sets the text colour associated with the menu item. More...
virtual void | SetAccel (wxAcceleratorEntry *accel)
| Set the accel for this item - this may also be done indirectly with SetText() More...
virtual void | AddExtraAccel (const wxAcceleratorEntry &accel)
| Add an extra accelerator for this menu item. More...
void | ClearExtraAccels ()
| Clear the extra accelerators list. More...
Public Member Functions inherited from wxObject
| wxObject ()
| Default ctor; initializes to nullptr the internal reference data. More...
| wxObject (const wxObject &other)
| Copy ctor. More...
virtual | ~wxObject ()
| Destructor. More...
virtual wxClassInfo * | GetClassInfo () const
| This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar). More...
wxObjectRefData * | GetRefData () const
| Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. More...
bool | IsKindOf (const wxClassInfo *info) const
| Determines whether this class is a subclass of (or the same class as) the given class. More...
bool | IsSameAs (const wxObject &obj) const
| Returns true if this object has the same data pointer as obj. More...
void | Ref (const wxObject &clone)
| Makes this object refer to the data in clone. More...
void | SetRefData (wxObjectRefData *data)
| Sets the wxObject::m_refData pointer. More...
void | UnRef ()
| Decrements the reference count in the associated data, and if it is zero, deletes the data. More...
void | UnShare ()
| This is the same of AllocExclusive() but this method is public. More...
void | operator delete (void *buf)
| The delete operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined. More...
void * | operator new (size_t size, const wxString &filename=nullptr, int lineNum=0)
| The new operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined. More...

## Static Public Member Functions
static wxString | GetLabelFromText (const wxString &text)
static wxString | GetLabelText (const wxString &text)
| Strips all accelerator characters and mnemonics from the given text. More...

## Additional Inherited Members
Protected Member Functions inherited from wxObject
void | AllocExclusive ()
| Ensure that this object's data is not shared with any other object. More...
virtual wxObjectRefData * | CreateRefData () const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. More...
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data. More...
Protected Attributes inherited from wxObject
wxObjectRefData * | m_refData
| Pointer to an object which is the object's reference-counted data. More...

## Constructor & Destructor Documentation

## ◆ wxMenuItem()

wxMenuItem::wxMenuItem | ( | wxMenu * | parentMenu = `nullptr`,
|  | int | id = `wxID_SEPARATOR`,
|  | const wxString & | text = `wxEmptyString`,
|  | const wxString & | helpString = `wxEmptyString`,
|  | wxItemKind | kind = `wxITEM_NORMAL`,
|  | wxMenu * | subMenu = `nullptr`
| ) |  |

Constructs a wxMenuItem object.

Menu items can be standard, or "stock menu items", or custom. For the standard menu items (such as commands to open a file, exit the program and so on, see Stock Items for the full list) it is enough to specify just the stock ID and leave text and helpString empty. Some platforms (currently wxGTK only, and see the remark in SetBitmap() documentation) will also show standard bitmaps for stock menu items.

Leaving at least text empty for the stock menu items is actually strongly recommended as they will have appearance and keyboard interface (including standard accelerators) familiar to the user.

For the custom (non-stock) menu items, text must be specified and while helpString may be left empty, it's recommended to pass the item description (which is automatically shown by the library in the status bar when the menu item is selected) in this parameter.

Finally note that you can e.g. use a stock menu label without using its stock help string:

// use all stock properties:
helpMenu->Append(wxID_ABOUT);
// use the stock label and the stock accelerator but not the stock help string:
helpMenu->Append(wxID_ABOUT, "", "My custom help string");
// use all stock properties except for the bitmap:
wxMenuItem *mymenu = new wxMenuItem(helpMenu, wxID_ABOUT);
mymenu->SetBitmap(wxArtProvider::GetBitmap(wxART_WARNING));
helpMenu->Append(mymenu);
wxART_WARNING
const char * wxART_WARNING
Definition: artprov.h:69
wxArtProvider::GetBitmap
static wxBitmap GetBitmap(const wxArtID &id, const wxArtClient &client=wxART_OTHER, const wxSize &size=wxDefaultSize)
Query registered providers for bitmap with given ID.
wxID_ABOUT
@ wxID_ABOUT
Definition: defs.h:615

that is, stock properties are set independently one from the other.

Parameters

  parentMenu | Menu that the menu item belongs to. Can be nullptr if the item is going to be added to the menu later.
  id | Identifier for this menu item. May be `wxID_SEPARATOR`, in which case the given kind is ignored and taken to be `wxITEM_SEPARATOR` instead.
  text | Text for the menu item, as shown on the menu. See SetItemLabel() for more info.
  helpString | Optional help string that will be shown on the status bar.
  kind | May be `wxITEM_SEPARATOR`, `wxITEM_NORMAL`, `wxITEM_CHECK` or `wxITEM_RADIO`.
  subMenu | If non-null, indicates that the menu item is a submenu.

## ◆ ~wxMenuItem()

virtual wxMenuItem::~wxMenuItem | ( |  | ) |
| virtual

Destructor.

## Member Function Documentation

## ◆ AddExtraAccel()

virtual void wxMenuItem::AddExtraAccel | ( | const wxAcceleratorEntry & | accel | ) |
| virtual

Add an extra accelerator for this menu item.

Additional accelerators are not shown in the item's label, but still will trigger the menu command when pressed.

They can be useful to let multiple keys be used as accelerators for the same command, e.g. `WXK_ADD` and `WXK_NUMPAD_ADD`.

Availability: only available for the wxMSW, wxGTK ports.

Since
  3.1.6

## ◆ Check()

virtual void wxMenuItem::Check | ( | bool | check = `true` | ) |
| virtual

Checks or unchecks the menu item.

Note that this only works when the item is already appended to a menu.

## ◆ ClearExtraAccels()

void wxMenuItem::ClearExtraAccels | ( |  | ) |

Clear the extra accelerators list.

This doesn't affect the main item accelerator (if any).

Since
  3.1.6

## ◆ Enable()

virtual void wxMenuItem::Enable | ( | bool | enable = `true` | ) |
| virtual

Enables or disables the menu item.

## ◆ GetAccel()

virtual wxAcceleratorEntry* wxMenuItem::GetAccel | ( |  | ) | const
| virtual

Get our accelerator or nullptr (caller must delete the pointer)

## ◆ GetAccelFromString()

static wxAcceleratorEntry* wxMenuItem::GetAccelFromString | ( | const wxString & | label | ) |
| static

Extract the accelerator from the given menu string, return nullptr if none found.

## ◆ GetBackgroundColour()

wxColour& wxMenuItem::GetBackgroundColour | ( |  | ) | const

Returns the background colour associated with the menu item.

Availability: only available for the wxMSW port.

## ◆ GetBitmap() [1/2]

wxBitmap wxMenuItem::GetBitmap | ( |  | ) | const

Returns the item bitmap.

This method exists only for compatibility, please use GetBitmapBundle() in the new code.

## ◆ GetBitmap() [2/2]

wxBitmap wxMenuItem::GetBitmap | ( | bool | checked | ) | const

Returns the checked or unchecked bitmap.

This overload only exists in wxMSW, avoid using it in portable code.

## ◆ GetBitmapBundle()

wxBitmapBundle wxMenuItem::GetBitmapBundle | ( |  | ) | const

Returns the bitmap bundle containing the bitmap used for this item.

The returned bundle is invalid, i.e. empty, if no bitmap is associated with the item.

See also
  SetBitmap()

Since
  3.2.0

## ◆ GetDisabledBitmap()

virtual wxBitmap wxMenuItem::GetDisabledBitmap | ( |  | ) | const
| virtual

Returns the bitmap used for disabled items.

Availability: only available for the wxMSW port.

## ◆ GetFont()

wxFont& wxMenuItem::GetFont | ( |  | ) | const

Returns the font associated with the menu item.

Availability: only available for the wxMSW port.

## ◆ GetHelp()

const wxString& wxMenuItem::GetHelp | ( |  | ) | const

Returns the help string associated with the menu item.

## ◆ GetId()

int wxMenuItem::GetId | ( |  | ) | const

Returns the menu item identifier.

## ◆ GetItemLabel()

virtual wxString wxMenuItem::GetItemLabel | ( |  | ) | const
| virtual

Returns the text associated with the menu item including any accelerator characters that were passed to the constructor or SetItemLabel().

See also
  GetItemLabelText(), GetLabelText()

## ◆ GetItemLabelText()

virtual wxString wxMenuItem::GetItemLabelText | ( |  | ) | const
| virtual

Returns the text associated with the menu item, without any accelerator characters.

See also
  GetItemLabel(), GetLabelText()

## ◆ GetKind()

wxItemKind wxMenuItem::GetKind | ( |  | ) | const

Returns the item kind, one of `wxITEM_SEPARATOR`, `wxITEM_NORMAL`, `wxITEM_CHECK` or `wxITEM_RADIO`.

## ◆ GetLabel()

wxString wxMenuItem::GetLabel | ( |  | ) | const

Returns the text associated with the menu item without any accelerator characters it might contain.

Deprecated:
  This function is deprecated in favour of GetItemLabelText().

See also
  GetItemLabelText()

## ◆ GetLabelFromText()

static wxString wxMenuItem::GetLabelFromText | ( | const wxString & | text | ) |
| static

Deprecated:
  This function is deprecated; please use GetLabelText() instead.

See also
  GetLabelText()

## ◆ GetLabelText()

static wxString wxMenuItem::GetLabelText | ( | const wxString & | text | ) |
| static

Strips all accelerator characters and mnemonics from the given text.

For example:

wxMenuItem::GetLabelText("&Hello\tCtrl-h");

will return just `"Hello"`.

See also
  GetItemLabelText(), GetItemLabel()

## ◆ GetMarginWidth()

int wxMenuItem::GetMarginWidth | ( |  | ) | const

Gets the width of the menu item checkmark bitmap.

Availability: only available for the wxMSW port.

## ◆ GetMenu()

wxMenu* wxMenuItem::GetMenu | ( |  | ) | const

Returns the menu this menu item is in, or nullptr if this menu item is not attached.

## ◆ GetName()

wxString wxMenuItem::GetName | ( |  | ) | const

Returns the text associated with the menu item.

Deprecated:
  This function is deprecated. Please use GetItemLabel() or GetItemLabelText() instead.

See also
  GetItemLabel(), GetItemLabelText()

## ◆ GetSubMenu()

wxMenu* wxMenuItem::GetSubMenu | ( |  | ) | const

Returns the submenu associated with the menu item, or nullptr if there isn't one.

## ◆ GetText()

const wxString& wxMenuItem::GetText | ( |  | ) | const

Returns the text associated with the menu item, such as it was passed to the wxMenuItem constructor, i.e. with any accelerator characters it may contain.

Deprecated:
  This function is deprecated in favour of GetItemLabel().

See also
  GetItemLabel()

## ◆ GetTextColour()

wxColour& wxMenuItem::GetTextColour | ( |  | ) | const

Returns the text colour associated with the menu item.

Availability: only available for the wxMSW port.

## ◆ IsCheck()

bool wxMenuItem::IsCheck | ( |  | ) | const

Returns true if the item is a check item.

Unlike IsCheckable() this doesn't return true for the radio buttons.

Since
  2.9.5

## ◆ IsCheckable()

bool wxMenuItem::IsCheckable | ( |  | ) | const

Returns true if the item is checkable.

Notice that the radio buttons are considered to be checkable as well, so this method returns true for them too. Use IsCheck() if you want to test for the check items only.

## ◆ IsChecked()

virtual bool wxMenuItem::IsChecked | ( |  | ) | const
| virtual

Returns true if the item is checked.

## ◆ IsEnabled()

virtual bool wxMenuItem::IsEnabled | ( |  | ) | const
| virtual

Returns true if the item is enabled.

## ◆ IsRadio()

bool wxMenuItem::IsRadio | ( |  | ) | const

Returns true if the item is a radio button.

Since
  2.9.5

## ◆ IsSeparator()

bool wxMenuItem::IsSeparator | ( |  | ) | const

Returns true if the item is a separator.

## ◆ IsSubMenu()

bool wxMenuItem::IsSubMenu | ( |  | ) | const

Returns true if the item is a submenu.

## ◆ SetAccel()

virtual void wxMenuItem::SetAccel | ( | wxAcceleratorEntry * | accel | ) |
| virtual

Set the accel for this item - this may also be done indirectly with SetText()

## ◆ SetBackgroundColour()

void wxMenuItem::SetBackgroundColour | ( | const wxColour & | colour | ) |

Sets the background colour associated with the menu item.

Please note that this function only exists in wxMSW and works by making the menu item "owner-drawn" there, please see the note about such items in this class description.

## ◆ SetBitmap() [1/2]

void wxMenuItem::SetBitmap | ( | const wxBitmapBundle & | bmp | ) |

Sets the bitmap for the menu item.

Notice that GTK+ uses a global setting called `gtk-menu-images` to determine if the images should be shown in the menus at all. If it is off (which is the case in e.g. Gnome 2.28 by default), no images will be shown, consistently with the native behaviour.

## ◆ SetBitmap() [2/2]

void wxMenuItem::SetBitmap | ( | const wxBitmapBundle & | bmp,
|  | bool | checked
| ) |  |

Sets the checked or unchecked bitmap for the menu item.

It is equivalent to wxMenuItem::SetBitmaps(bmp, wxNullBitmap) if checked is true or SetBitmaps(wxNullBitmap, bmp) otherwise.

Note that different bitmaps for checked and unchecked item states are not supported in most ports, while setting just a single bitmap using the overload above is supported in all of them.

Availability: only available for the wxMSW port.

## ◆ SetBitmaps()

void wxMenuItem::SetBitmaps | ( | const wxBitmapBundle & | checked,
|  | const wxBitmapBundle & | unchecked = `wxNullBitmap`
| ) |  |

Sets the checked/unchecked bitmaps for the menu item.

The first bitmap is also used as the single bitmap for uncheckable menu items.

Availability: only available for the wxMSW port.

## ◆ SetDisabledBitmap()

void wxMenuItem::SetDisabledBitmap | ( | const wxBitmapBundle & | disabled | ) |

Sets the to be used for disabled menu items.

Availability: only available for the wxMSW port.

## ◆ SetFont()

void wxMenuItem::SetFont | ( | const wxFont & | font | ) |

Sets the font associated with the menu item.

Please note that this function only exists in wxMSW and works by making the menu item "owner-drawn" there, please see the note about such items in this class description.

## ◆ SetHelp()

void wxMenuItem::SetHelp | ( | const wxString & | helpString | ) |

Sets the help string.

## ◆ SetItemLabel()

virtual void wxMenuItem::SetItemLabel | ( | const wxString & | label | ) |
| virtual

Sets the label associated with the menu item.

Note that if the ID of this menu item corresponds to a stock ID, then it is not necessary to specify a label: wxWidgets will automatically use the stock item label associated with that ID. See the constructor for more info.

The label string for the normal menu items (not separators) may include the accelerator which can be used to activate the menu item from keyboard. An accelerator key can be specified using the ampersand `&` character. In order to embed an ampersand character in the menu item text, the ampersand must be doubled.

Optionally you can specify also an accelerator string appending a tab character `\t` followed by a valid key combination (e.g. `CTRL+V`). Its general syntax is any combination of `"CTRL"`, `"RAWCTRL"`, `"ALT"` and `"SHIFT"` strings (case doesn't matter) separated by either `'-'` or `'+'` characters and followed by the accelerator itself. Note that the displayed accelerator can differ from the string specified here though, e.g. `Ctrl+X` could be actually shown on the screen when `Ctrl-X` is used. Notice that `CTRL` corresponds to the "Ctrl" key on most platforms but not under macOS where it is mapped to "Cmd" key on Mac keyboard. Usually this is exactly what you want in portable code but if you really need to use the (rarely used for this purpose) "Ctrl" key even under Mac, you may use `RAWCTRL` to prevent this mapping. Under the other platforms `RAWCTRL` is the same as plain `CTRL`.

The accelerator may be any alphanumeric character, any function key (from `F1` to `F12`), any numpad digit key using `KP_` prefix (i.e. from `KP_0` to `KP_9`) or one of the special strings listed below (again, case doesn't matter) corresponding to the specified key code:

- `Del` or `Delete:` WXK_DELETE
- `Back:` WXK_BACK
- `Ins` or `Insert:` WXK_INSERT
- `Enter` or `Return:` WXK_RETURN
- `PgUp` or `PageUp:` WXK_PAGEUP
- `PgDn` or `PageDown:` WXK_PAGEDOWN
- `Left:` WXK_LEFT
- `Right:` WXK_RIGHT
- `Up:` WXK_UP
- `Down:` WXK_DOWN
- `Home:` WXK_HOME
- `End:` WXK_END
- `Space:` WXK_SPACE
- `Tab:` WXK_TAB
- `Esc` or `Escape:` WXK_ESCAPE
- `Cancel:` WXK_CANCEL
- `Clear:` WXK_CLEAR
- `Menu:` WXK_MENU
- `Pause:` WXK_PAUSE
- `Capital:` WXK_CAPITAL
- `Select:` WXK_SELECT
- `Print:` WXK_PRINT
- `Execute:` WXK_EXECUTE
- `Snapshot:` WXK_SNAPSHOT
- `Help:` WXK_HELP
- `Add:` WXK_ADD
- `Separator:` WXK_SEPARATOR
- `Subtract:` WXK_SUBTRACT
- `Decimal:` WXK_DECIMAL
- `Divide:` WXK_DIVIDE
- `Num_lock:` WXK_NUMLOCK
- `Scroll_lock:` WXK_SCROLL
- `KP_Space:` WXK_NUMPAD_SPACE
- `KP_Tab:` WXK_NUMPAD_TAB
- `KP_Enter:` WXK_NUMPAD_ENTER
- `KP_Home:` WXK_NUMPAD_HOME
- `KP_Left:` WXK_NUMPAD_LEFT
- `KP_Up:` WXK_NUMPAD_UP
- `KP_Right:` WXK_NUMPAD_RIGHT
- `KP_Down:` WXK_NUMPAD_DOWN
- `KP_PageUp:` WXK_NUMPAD_PAGEUP
- `KP_PageDown:` WXK_NUMPAD_PAGEDOWN
- `KP_Prior:` WXK_NUMPAD_PAGEUP
- `KP_Next:` WXK_NUMPAD_PAGEDOWN
- `KP_End:` WXK_NUMPAD_END
- `KP_Begin:` WXK_NUMPAD_BEGIN
- `KP_Insert:` WXK_NUMPAD_INSERT
- `KP_Delete:` WXK_NUMPAD_DELETE
- `KP_Equal:` WXK_NUMPAD_EQUAL
- `KP_Multiply:` WXK_NUMPAD_MULTIPLY
- `KP_Add:` WXK_NUMPAD_ADD
- `KP_Separator:` WXK_NUMPAD_SEPARATOR
- `KP_Subtract:` WXK_NUMPAD_SUBTRACT
- `KP_Decimal:` WXK_NUMPAD_DECIMAL
- `KP_Divide:` WXK_NUMPAD_DIVIDE
- `Windows_Left:` WXK_WINDOWS_LEFT
- `Windows_Right:` WXK_WINDOWS_RIGHT
- `Windows_Menu:` WXK_WINDOWS_MENU
- `Command:` WXK_COMMAND

Examples:

m_pMyMenuItem->SetItemLabel("My &item\tCTRL+I");
m_pMyMenuItem2->SetItemLabel("Clean && build\tF7");
m_pMyMenuItem3->SetItemLabel("Simple item");
m_pMyMenuItem4->SetItemLabel("Item with &accelerator");

Note
  In wxGTK using `"SHIFT"` with non-alphabetic characters currently doesn't work, even in combination with other modifiers, due to GTK+ limitation. E.g. `Shift+Ctrl+A` works but `Shift+Ctrl+1` or `Shift+/` do not, so avoid using accelerators of this form in portable code.
  In wxGTk, the left/right/up/down arrow keys do not work as accelerator keys for a menu item unless a modifier key is used. Additionally, the following keycodes are not supported as menu accelerator keys:
  - WXK_COMMAND/WXK_CONTROL
  - WXK_SHIFT
  - WXK_ALT
  - WXK_SCROLL
  - WXK_CAPITAL
  - WXK_NUMLOCK
  - WXK_NUMPAD_TAB
  - WXK_TAB
  - WXK_WINDOWS_LEFT
  - WXK_WINDOWS_RIGHT
  - WXK_ADD
  - WXK_SEPARATOR
  - WXK_SUBTRACT
  - WXK_DECIMAL
  - WXK_DIVIDE
  - WXK_SNAPSHOT

See also
  GetItemLabel(), GetItemLabelText()

## ◆ SetMarginWidth()

void wxMenuItem::SetMarginWidth | ( | int | width | ) |

Sets the width of the menu item checkmark bitmap.

Availability: only available for the wxMSW port.

## ◆ SetMenu()

void wxMenuItem::SetMenu | ( | wxMenu * | menu | ) |

Sets the parent menu which will contain this menu item.

## ◆ SetSubMenu()

void wxMenuItem::SetSubMenu | ( | wxMenu * | menu | ) |

Sets the submenu of this menu item.

## ◆ SetText()

virtual void wxMenuItem::SetText | ( | const wxString & | text | ) |
| virtual

Sets the text associated with the menu item.

Deprecated:
  This function is deprecated in favour of SetItemLabel().

See also
  SetItemLabel().

## ◆ SetTextColour()

void wxMenuItem::SetTextColour | ( | const wxColour & | colour | ) |

Sets the text colour associated with the menu item.

Please note that this function only exists in wxMSW and works by making the menu item "owner-drawn" there, please see the note about such items in this class description.