wxMenuItem(3)
wxMenuItem(3) β Erlang Module Definition π
okay bestie, welcome to the wxMenuItem page π this is the Erlang module definition flavor, and it's a long one, so buckle up.
NAME β¨
wxMenuItem β a menu item represents an item in a menu. that's it, that's the girl π
DESCRIPTION πΈ
ngl, you usually don't have to deal with this class directly, because wxMenu methods basically construct one of these for you. it's giving "the popular girl does the intro for you" energy. π
also please note, fr fr: the methods related to fonts and bitmaps are currently only implemented for Windows, Mac and GTK+. so don't come for what isn't there on your platform, k? π
see also:
wxMenuBarwxMenu
wxWidgets docs: wxMenuItem
Events π¦
event types emitted from this class:
menu_openmenu_closemenu_highlight
DATA TYPES π
wxMenuItem() :: wx:wx_object().
FUNCTIONS π
check(This, [Option]) -> ok
check(This, [Option]) -> ok
when This :: wxMenuItem(), Option :: {check, boolean()}.
checks or unchecks the menu item. lowkey does what it says on the tin β¨
note it: this only works when the item is already appended to a menu. so if you're out here calling it on a loose item, bestie, that's a you problem π
destroy(This :: wxMenuItem()) -> ok
destroys the object π iconic exit, no notes.
enable(This, [Option]) -> ok
enable(This, [Option]) -> ok
when This :: wxMenuItem(), Option :: {enable, boolean()}.
enables or disables the menu item. vibe check, but for clickability π«Ά
getBitmap(This) -> wxBitmap:wxBitmap()
getBitmap(This) -> wxBitmap:wxBitmap() when This :: wxMenuItem().
returns the checked or unchecked bitmap.
Only for: wxmsw
getHelp(This) -> unicode:charlist()
getHelp(This) -> unicode:charlist() when This :: wxMenuItem().
returns the help string associated with the menu item. the little supportive text, she's doing her best π₯Ί
getId(This) -> integer()
getId(This) -> integer() when This :: wxMenuItem().
returns the menu item identifier. her government name, basically π
getItemLabel(This) -> unicode:charlist()
getItemLabel(This) -> unicode:charlist() when This :: wxMenuItem().
returns the text associated with the menu item including any accelerator characters that were passed to the constructor or to setItemLabel/2.
see:
getItemLabelText/1getLabelText/1
getItemLabelText(This) -> unicode:charlist()
getItemLabelText(This) -> unicode:charlist()
when This :: wxMenuItem().
returns the text associated with the menu item, without any accelerator characters. so like, the clean face, no filter, no extra keys π₯
see:
getItemLabel/1getLabelText/1
getKind(This) -> wx:wx_enum()
getKind(This) -> wx:wx_enum() when This :: wxMenuItem().
returns the item kind, one of wxITEM_SEPARATOR, wxITEM_NORMAL, wxITEM_CHECK or wxITEM_RADIO. pick your fighter β
getLabel(This) -> unicode:charlist()
getLabel(This) -> unicode:charlist() when This :: wxMenuItem().
equivalent to: getItemLabelText/1
getLabelFromText(Text) -> unicode:charlist()
getLabelFromText(Text) -> unicode:charlist()
when Text :: unicode:chardata().
equivalent to: getLabelText/1
getLabelText(Text) -> unicode:charlist()
getLabelText(Text) -> unicode:charlist()
when Text :: unicode:chardata().
strips all accelerator characters and mnemonics from the given text. she's taking the ampersands away, periodt βοΈ
for example:
will return just "Hello".
see:
getItemLabelText/1getItemLabel/1
getMenu(This) -> wxMenu:wxMenu()
getMenu(This) -> wxMenu:wxMenu() when This :: wxMenuItem().
returns the menu this menu item is in, or NULL if this menu item is not attached. she's single and ready to mingle π¦ (or, y'know, fully claimed, depends π
)
getSubMenu(This) -> wxMenu:wxMenu()
getSubMenu(This) -> wxMenu:wxMenu() when This :: wxMenuItem().
returns the submenu associated with the menu item, or NULL if there isn't one. no submenu, no sub-plot π
getText(This) -> unicode:charlist()
getText(This) -> unicode:charlist() when This :: wxMenuItem().
equivalent to: getItemLabel/1
isCheckable(This) -> boolean()
isCheckable(This) -> boolean() when This :: wxMenuItem().
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() (not implemented in wx) if you want to test for the check items only. so like, don't get it twisted π
isChecked(This) -> boolean()
isChecked(This) -> boolean() when This :: wxMenuItem().
returns true if the item is checked. β
isEnabled(This) -> boolean()
isEnabled(This) -> boolean() when This :: wxMenuItem().
returns true if the item is enabled.
isSeparator(This) -> boolean()
isSeparator(This) -> boolean() when This :: wxMenuItem().
returns true if the item is a separator. the little line, doing the most by doing nothing β¨
isSubMenu(This) -> boolean()
isSubMenu(This) -> boolean() when This :: wxMenuItem().
returns true if the item is a submenu.
new([Option]) -> wxMenuItem()
new([Option]) -> wxMenuItem()
when
Option ::
{parentMenu, wxMenu:wxMenu()} |
{id, integer()} |
{text, unicode:chardata()} |
{help, unicode:chardata()} |
{kind, wx:wx_enum()} |
{subMenu, wxMenu:wxMenu()}.
constructs a wxMenuItem object. hello world, but make it menu π
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 page_stockitems for the full list) it is enough to specify just the stock ID and leave text and help string empty. some platforms (currently wxGTK only, and see the remark in setBitmap/2 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. trust the process, bestie, the platform knows what it's doing π
for the custom (non-stock) menu items, text must be specified, and while the help string 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. cute and informative π₯°
finally, note that you can e.g. use a stock menu label without using its stock help string:
that is, stock properties are set independently one from the other. no bundling, no package deals π€
setBitmap(This, Bmp) -> ok
setBitmap(This, Bmp) -> ok
when This :: wxMenuItem(), Bmp :: wxBitmap:wxBitmap().
sets the bitmap for the menu item.
it is equivalent to wxMenuItem::SetBitmaps(bmp, wxNullBitmap) if checked is true (default value) or SetBitmaps(wxNullBitmap, bmp) otherwise.
setBitmap/2 must be called before the item is appended to the menu, i.e. appending the item without a bitmap and setting one later is not guaranteed to work. so do it in the right order or suffer the consequences π but the bitmap can be changed or reset later if it had been set up initially.
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.
Only for: wxmsw,wxosx,wxgtk
setHelp(This, HelpString) -> ok
setHelp(This, HelpString) -> ok
when
This :: wxMenuItem(),
HelpString :: unicode:chardata().
sets the help string. that's the whole bit π«Ά
setItemLabel(This, Label) -> ok
setItemLabel(This, Label) -> ok
when
This :: wxMenuItem(),
Label :: unicode:chardata().
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 new/1 for more info. she handles it, don't worry β¨
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. double it or lose it, periodt π
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. 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. so RAWCTRL is giving "i said what i said" energy π₯
the accelerator may be any alphanumeric character, any function key (from F1 to F12), any numpad digit key using the 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:
DelorDelete:WXK_DELETEBack:WXK_BACKInsorInsert:WXK_INSERTEnterorReturn:WXK_RETURNPgUporPageUp:WXK_PAGEUPPgDnorPageDown:WXK_PAGEDOWNLeft:WXK_LEFTRight:WXK_RIGHTUp:WXK_UPDown:WXK_DOWNHome:WXK_HOMEEnd:WXK_ENDSpace:WXK_SPACETab:WXK_TABEscorEscape:WXK_ESCAPECancel:WXK_CANCELClear:WXK_CLEARMenu:WXK_MENUPause:WXK_PAUSECapital:WXK_CAPITALSelect:WXK_SELECTPrint:WXK_PRINTExecute:WXK_EXECUTESnapshot:WXK_SNAPSHOTHelp:WXK_HELPAdd:WXK_ADDSeparator:WXK_SEPARATORSubtract:WXK_SUBTRACTDecimal:WXK_DECIMALDivide:WXK_DIVIDENum_lock:WXK_NUMLOCKScroll_lock:WXK_SCROLLKP_Space:WXK_NUMPAD_SPACEKP_Tab:WXK_NUMPAD_TABKP_Enter:WXK_NUMPAD_ENTERKP_Home:WXK_NUMPAD_HOMEKP_Left:WXK_NUMPAD_LEFTKP_Up:WXK_NUMPAD_UPKP_Right:WXK_NUMPAD_RIGHTKP_Down:WXK_NUMPAD_DOWNKP_PageUp:WXK_NUMPAD_PAGEUPKP_PageDown:WXK_NUMPAD_PAGEDOWNKP_Prior:WXK_NUMPAD_PAGEUPKP_Next:WXK_NUMPAD_PAGEDOWNKP_End:WXK_NUMPAD_ENDKP_Begin:WXK_NUMPAD_BEGINKP_Insert:WXK_NUMPAD_INSERTKP_Delete:WXK_NUMPAD_DELETEKP_Equal:WXK_NUMPAD_EQUALKP_Multiply:WXK_NUMPAD_MULTIPLYKP_Add:WXK_NUMPAD_ADDKP_Separator:WXK_NUMPAD_SEPARATORKP_Subtract:WXK_NUMPAD_SUBTRACTKP_Decimal:WXK_NUMPAD_DECIMALKP_DivideβWXK_NUMPAD_DIVIDEπWindows_LeftβWXK_WINDOWS_LEFTπͺWindows_RightβWXK_WINDOWS_RIGHTπͺWindows_MenuβWXK_WINDOWS_MENUπͺCommandβWXK_COMMANDπ
and that's the whole mapping list, bestie β done, dusted, periodt. β¨
β¨ Examples
The page literally goes Examples: and then leaves you on read π there's no sample code printed right here, so that's honestly all this bit gives you.
π¨ Notes (read these fr fr, they matter)
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. π
Note: 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 β like, at all, no cap:
WXK_COMMAND/WXK_CONTROLWXK_SHIFTWXK_ALTWXK_SCROLLWXK_CAPITALWXK_NUMLOCKWXK_NUMPAD_TABWXK_TABWXK_WINDOWS_LEFTWXK_WINDOWS_RIGHTWXK_ADDWXK_SEPARATORWXK_SUBTRACTWXK_DECIMALWXK_DIVIDEWXK_SNAPSHOT
π See:
getItemLabel/1getItemLabelText/1
π«Ά setMenu
setMenu(This, Menu) -> ok
when This :: wxMenuItem(), Menu :: wxMenu:wxMenu().
This one sets the parent menu which will contain this menu item β like, you're telling the item which menu is its home, the one that's gonna hold it. π π
π¦ setSubMenu
setSubMenu(This, Menu) -> ok
when This :: wxMenuItem(), Menu :: wxMenu:wxMenu().
And this sets the submenu of this menu item. Give your item a little dropdown of its own, main character energy fr. π₯
π setText
setText(This, Label) -> ok
when This :: wxMenuItem(), Label :: unicode:chardata().
Equivalent to: setItemLabel/2 β literally the same thing, just a different name on the door, bestie. Same vibe, same result. π
and that's a wrap on wxMenuItem(3)!! πΈ this page comes to you from Ericsson AB, it's the wx 2.6 era energy, and yeah, the date stamp is whatever your local copy is rockin' β go check your own terminal for that one, iykyk ππ«Ά slay, go build a menu, you got this β¨π
π¦ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms