.TH wxMenu 3erl "wx 2.2.2.1" "wxWidgets team." "Erlang Module Definition" .SH NAME wxMenu \- Functions for wxMenu class .SH DESCRIPTION .LP A menu is a popup (or pull down) list of items, one of which may be selected before the menu goes away (clicking elsewhere dismisses the menu)\&. Menus may be used to construct either menu bars or popup menus\&. .LP A menu item has an integer ID associated with it which can be used to identify the selection, or to change the menu item in some way\&. A menu item with a special identifier \fIwxID_SEPARATOR\fR\& is a separator item and doesn\&'t have an associated command but just makes a separator line appear in the menu\&. .LP Note: Please note that \fIwxID_ABOUT\fR\& and \fIwxID_EXIT\fR\& are predefined by wxWidgets and have a special meaning since entries using these IDs will be taken out of the normal menus under macOS and will be inserted into the system menu (following the appropriate macOS interface guideline)\&. .LP Menu items may be either \fInormal\fR\& items, \fIcheck\fR\& items or \fIradio\fR\& items\&. Normal items don\&'t have any special properties while the check items have a boolean flag associated to them and they show a checkmark in the menu when the flag is set\&. wxWidgets automatically toggles the flag value when the item is clicked and its value may be retrieved using either \fIisChecked/2\fR\& method of \fIwxMenu\fR\& or \fIwxMenuBar\fR\& itself or by using wxEvent::IsChecked when you get the menu notification for the item in question\&. .LP The radio items are similar to the check items except that all the other items in the same radio group are unchecked when a radio item is checked\&. The radio group is formed by a contiguous range of radio items, i\&.e\&. it starts at the first item of this kind and ends with the first item of a different kind (or the end of the menu)\&. Notice that because the radio groups are defined in terms of the item positions inserting or removing the items in the menu containing the radio items risks to not work correctly\&. .LP Allocation strategy .LP All menus must be created on the \fIheap\fR\& because all menus attached to a menubar or to another menu will be deleted by their parent when it is deleted\&. The only exception to this rule are the popup menus (i\&.e\&. menus used with \fIwxWindow:popupMenu/4\fR\&) as wxWidgets does not destroy them to allow reusing the same menu more than once\&. But the exception applies only to the menus themselves and not to any submenus of popup menus which are still destroyed by wxWidgets as usual and so must be heap-allocated\&. .LP As the frame menubar is deleted by the frame itself, it means that normally all menus used are deleted automatically\&. .LP Event handling .LP Event handlers for the commands generated by the menu items can be connected directly to the menu object itself using \fIwxEvtHandler::Bind()\fR\& (not implemented in wx)\&. If this menu is a submenu of another one, the events from its items can also be processed in the parent menu and so on, recursively\&. .LP If the menu is part of a menu bar, then events can also be handled in \fIwxMenuBar\fR\& object\&. .LP Finally, menu events can also be handled in the associated window, which is either the \fIwxFrame\fR\& associated with the menu bar this menu belongs to or the window for which \fIwxWindow:popupMenu/4\fR\& was called for the popup menus\&. .LP See overview_events_bind for how to bind event handlers to the various objects\&. .LP See: \fIwxMenuBar\fR\&, \fIwxWindow:popupMenu/4\fR\&, Overview events, \fIwxFileHistory\fR\& (not implemented in wx) .LP This class is derived (and can use functions) from: \fIwxEvtHandler\fR\& .LP wxWidgets docs: wxMenu .SH DATA TYPES .nf \fBwxMenu()\fR\& = wx:wx_object() .br .fi .SH EXPORTS .LP .nf .B new() -> wxMenu() .br .fi .br .RS .LP Constructs a \fIwxMenu\fR\& object\&. .RE .LP .nf .B new(Options :: [Option]) -> wxMenu() .br .fi .br .RS .LP Types: .RS 3 Option = {style, integer()} .br .RE .RE .RS .LP Constructs a \fIwxMenu\fR\& object\&. .RE .LP .nf .B new(Title, Options :: [Option]) -> wxMenu() .br .fi .br .RS .LP Types: .RS 3 Title = unicode:chardata() .br Option = {style, integer()} .br .RE .RE .RS .LP Constructs a \fIwxMenu\fR\& object with a title\&. .RE .LP .nf .B destroy(This :: wxMenu()) -> ok .br .fi .br .RS .LP Destructor, destroying the menu\&. .LP Note: Under Motif, a popup menu must have a valid parent (the window it was last popped up on) when being destroyed\&. Therefore, make sure you delete or re-use the popup menu \fIbefore\fR\& destroying the parent window\&. Re-use in this context means popping up the menu on a different window from last time, which causes an implicit destruction and recreation of internal data structures\&. .RE .LP .nf .B append(This, MenuItem) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br MenuItem = wxMenuItem:wxMenuItem() .br .RE .RE .RS .LP Adds a menu item object\&. .LP This is the most generic variant of \fIappend/5\fR\& method because it may be used for both items (including separators) and submenus and because you can also specify various extra properties of a menu item this way, such as bitmaps and fonts\&. .LP Remark: See the remarks for the other \fIappend/5\fR\& overloads\&. .LP See: \fIappendSeparator/1\fR\&, \fIappendCheckItem/4\fR\&, \fIappendRadioItem/4\fR\&, \fIAppendSubMenu()\fR\& (not implemented in wx), \fIinsert/6\fR\&, \fIsetLabel/3\fR\&, \fIgetHelpString/2\fR\&, \fIsetHelpString/3\fR\&, \fIwxMenuItem\fR\& .RE .LP .nf .B append(This, Id, Item) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br Item = unicode:chardata() .br .RE .RE .LP .nf .B append(This, Id, Item, SubMenu) -> wxMenuItem:wxMenuItem() .br .fi .br .nf .B append(This, Id, Item, SubMenu :: [Option]) -> .B wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br Item = unicode:chardata() .br Option = {help, unicode:chardata()} | {kind, wx:wx_enum()} .br .RE .RE .RS .LP Adds a menu item\&. .LP Example: .LP or even better for stock menu items (see \fIwxMenuItem:new/1\fR\&): .LP Remark: This command can be used after the menu has been shown, as well as on initial creation of a menu or menubar\&. .LP See: \fIappendSeparator/1\fR\&, \fIappendCheckItem/4\fR\&, \fIappendRadioItem/4\fR\&, \fIAppendSubMenu()\fR\& (not implemented in wx), \fIinsert/6\fR\&, \fIsetLabel/3\fR\&, \fIgetHelpString/2\fR\&, \fIsetHelpString/3\fR\&, \fIwxMenuItem\fR\& .RE .LP .nf .B append(This, Id, Item, SubMenu, Options :: [Option]) -> .B wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br Item = unicode:chardata() .br SubMenu = wxMenu() .br Option = {help, unicode:chardata()} .br .RE .RE .RS .LP Adds a submenu\&. .LP Deprecated: This function is deprecated, use \fIAppendSubMenu()\fR\& (not implemented in wx) instead\&. .LP See: \fIappendSeparator/1\fR\&, \fIappendCheckItem/4\fR\&, \fIappendRadioItem/4\fR\&, \fIAppendSubMenu()\fR\& (not implemented in wx), \fIinsert/6\fR\&, \fIsetLabel/3\fR\&, \fIgetHelpString/2\fR\&, \fIsetHelpString/3\fR\&, \fIwxMenuItem\fR\& .RE .LP .nf .B appendCheckItem(This, Id, Item) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br Item = unicode:chardata() .br .RE .RE .LP .nf .B appendCheckItem(This, Id, Item, Options :: [Option]) -> .B wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br Item = unicode:chardata() .br Option = {help, unicode:chardata()} .br .RE .RE .RS .LP Adds a checkable item to the end of the menu\&. .LP See: \fIappend/5\fR\&, \fIinsertCheckItem/5\fR\& .RE .LP .nf .B appendRadioItem(This, Id, Item) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br Item = unicode:chardata() .br .RE .RE .LP .nf .B appendRadioItem(This, Id, Item, Options :: [Option]) -> .B wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br Item = unicode:chardata() .br Option = {help, unicode:chardata()} .br .RE .RE .RS .LP Adds a radio item to the end of the menu\&. .LP All consequent radio items form a group and when an item in the group is checked, all the others are automatically unchecked\&. .LP Note: Radio items are not supported under wxMotif\&. .LP See: \fIappend/5\fR\&, \fIinsertRadioItem/5\fR\& .RE .LP .nf .B appendSeparator(This) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br .RE .RE .RS .LP Adds a separator to the end of the menu\&. .LP See: \fIappend/5\fR\&, \fIinsertSeparator/2\fR\& .RE .LP .nf .B break(This) -> ok .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br .RE .RE .RS .LP Inserts a break in a menu, causing the next appended item to appear in a new column\&. .LP This function only actually inserts a break in wxMSW and does nothing under the other platforms\&. .RE .LP .nf .B check(This, Id, Check) -> ok .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br Check = boolean() .br .RE .RE .RS .LP Checks or unchecks the menu item\&. .LP See: \fIisChecked/2\fR\& .RE .LP .nf .B delete(This, Id) -> boolean() .br .fi .br .nf .B delete(This, Item) -> boolean() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Item = wxMenuItem:wxMenuItem() .br .RE .RE .RS .LP Deletes the menu item from the menu\&. .LP If the item is a submenu, it will \fInot\fR\& be deleted\&. Use \fI\&'Destroy\&'/2\fR\& if you want to delete a submenu\&. .LP See: \fIfindItem/2\fR\&, \fI\&'Destroy\&'/2\fR\&, \fIremove/2\fR\& .RE .LP .nf .B \&'Destroy\&'(This, Id) -> boolean() .br .fi .br .nf .B \&'Destroy\&'(This, Item) -> boolean() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Item = wxMenuItem:wxMenuItem() .br .RE .RE .RS .LP Deletes the menu item from the menu\&. .LP If the item is a submenu, it will be deleted\&. Use \fIremove/2\fR\& if you want to keep the submenu (for example, to reuse it later)\&. .LP See: \fIfindItem/2\fR\&, \fIdelete/2\fR\&, \fIremove/2\fR\& .RE .LP .nf .B enable(This, Id, Enable) -> ok .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br Enable = boolean() .br .RE .RE .RS .LP Enables or disables (greys out) a menu item\&. .LP See: \fIisEnabled/2\fR\& .RE .LP .nf .B findItem(This, Id) -> wxMenuItem:wxMenuItem() .br .fi .br .nf .B findItem(This, ItemString) -> integer() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br ItemString = unicode:chardata() .br .RE .RE .RS .LP Finds the menu id for a menu item string\&. .LP Return: Menu item identifier, or wxNOT_FOUND if none is found\&. .LP Remark: Any special menu codes are stripped out of source and target strings before matching\&. .RE .LP .nf .B findItemByPosition(This, Position) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Position = integer() .br .RE .RE .RS .LP Returns the \fIwxMenuItem\fR\& given a position in the menu\&. .RE .LP .nf .B getHelpString(This, Id) -> unicode:charlist() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br .RE .RE .RS .LP Returns the help string associated with a menu item\&. .LP Return: The help string, or the empty string if there is no help string or the item was not found\&. .LP See: \fIsetHelpString/3\fR\&, \fIappend/5\fR\& .RE .LP .nf .B getLabel(This, Id) -> unicode:charlist() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br .RE .RE .RS .LP Returns a menu item label\&. .LP Return: The item label, or the empty string if the item was not found\&. .LP See: \fIGetLabelText()\fR\& (not implemented in wx), \fIsetLabel/3\fR\& .RE .LP .nf .B getMenuItemCount(This) -> integer() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br .RE .RE .RS .LP Returns the number of items in the menu\&. .RE .LP .nf .B getMenuItems(This) -> [wxMenuItem:wxMenuItem()] .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br .RE .RE .RS .RE .LP .nf .B getTitle(This) -> unicode:charlist() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br .RE .RE .RS .LP Returns the title of the menu\&. .LP See: \fIsetTitle/2\fR\& .RE .LP .nf .B insert(This, Pos, Id) -> wxMenuItem:wxMenuItem() .br .fi .br .nf .B insert(This, Pos, MenuItem) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Pos = integer() .br MenuItem = wxMenuItem:wxMenuItem() .br .RE .RE .RS .LP Inserts the given \fIitem\fR\& before the position \fIpos\fR\&\&. .LP Inserting the item at position \fIgetMenuItemCount/1\fR\& is the same as appending it\&. .LP See: \fIappend/5\fR\&, \fIprepend/5\fR\& .RE .LP .nf .B insert(This, Pos, Id, Options :: [Option]) -> .B wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Pos = Id = integer() .br Option = .br {text, unicode:chardata()} | .br {help, unicode:chardata()} | .br {kind, wx:wx_enum()} .br .RE .RE .RS .LP Inserts the given \fIitem\fR\& before the position \fIpos\fR\&\&. .LP Inserting the item at position \fIgetMenuItemCount/1\fR\& is the same as appending it\&. .LP See: \fIappend/5\fR\&, \fIprepend/5\fR\& .RE .LP .nf .B insert(This, Pos, Id, Text, Submenu) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Pos = Id = integer() .br Text = unicode:chardata() .br Submenu = wxMenu() .br .RE .RE .LP .nf .B insert(This, Pos, Id, Text, Submenu, Options :: [Option]) -> .B wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Pos = Id = integer() .br Text = unicode:chardata() .br Submenu = wxMenu() .br Option = {help, unicode:chardata()} .br .RE .RE .RS .LP Inserts the given \fIsubmenu\fR\& before the position \fIpos\fR\&\&. .LP \fItext\fR\& is the text shown in the menu for it and \fIhelp\fR\& is the help string shown in the status bar when the submenu item is selected\&. .LP See: \fIAppendSubMenu()\fR\& (not implemented in wx), \fIprepend/5\fR\& .RE .LP .nf .B insertCheckItem(This, Pos, Id, Item) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Pos = Id = integer() .br Item = unicode:chardata() .br .RE .RE .LP .nf .B insertCheckItem(This, Pos, Id, Item, Options :: [Option]) -> .B wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Pos = Id = integer() .br Item = unicode:chardata() .br Option = {help, unicode:chardata()} .br .RE .RE .RS .LP Inserts a checkable item at the given position\&. .LP See: \fIinsert/6\fR\&, \fIappendCheckItem/4\fR\& .RE .LP .nf .B insertRadioItem(This, Pos, Id, Item) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Pos = Id = integer() .br Item = unicode:chardata() .br .RE .RE .LP .nf .B insertRadioItem(This, Pos, Id, Item, Options :: [Option]) -> .B wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Pos = Id = integer() .br Item = unicode:chardata() .br Option = {help, unicode:chardata()} .br .RE .RE .RS .LP Inserts a radio item at the given position\&. .LP See: \fIinsert/6\fR\&, \fIappendRadioItem/4\fR\& .RE .LP .nf .B insertSeparator(This, Pos) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Pos = integer() .br .RE .RE .RS .LP Inserts a separator at the given position\&. .LP See: \fIinsert/6\fR\&, \fIappendSeparator/1\fR\& .RE .LP .nf .B isChecked(This, Id) -> boolean() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br .RE .RE .RS .LP Determines whether a menu item is checked\&. .LP Return: true if the menu item is checked, false otherwise\&. .LP See: \fIcheck/3\fR\& .RE .LP .nf .B isEnabled(This, Id) -> boolean() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br .RE .RE .RS .LP Determines whether a menu item is enabled\&. .LP Return: true if the menu item is enabled, false otherwise\&. .LP See: \fIenable/3\fR\& .RE .LP .nf .B prepend(This, Id) -> wxMenuItem:wxMenuItem() .br .fi .br .nf .B prepend(This, Item) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Item = wxMenuItem:wxMenuItem() .br .RE .RE .RS .LP Inserts the given \fIitem\fR\& at position 0, i\&.e\&. before all the other existing items\&. .LP See: \fIappend/5\fR\&, \fIinsert/6\fR\& .RE .LP .nf .B prepend(This, Id, Options :: [Option]) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br Option = .br {text, unicode:chardata()} | .br {help, unicode:chardata()} | .br {kind, wx:wx_enum()} .br .RE .RE .RS .LP Inserts the given \fIitem\fR\& at position 0, i\&.e\&. before all the other existing items\&. .LP See: \fIappend/5\fR\&, \fIinsert/6\fR\& .RE .LP .nf .B prepend(This, Id, Text, Submenu) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br Text = unicode:chardata() .br Submenu = wxMenu() .br .RE .RE .LP .nf .B prepend(This, Id, Text, Submenu, Options :: [Option]) -> .B wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br Text = unicode:chardata() .br Submenu = wxMenu() .br Option = {help, unicode:chardata()} .br .RE .RE .RS .LP Inserts the given \fIsubmenu\fR\& at position 0\&. .LP See: \fIAppendSubMenu()\fR\& (not implemented in wx), \fIinsert/6\fR\& .RE .LP .nf .B prependCheckItem(This, Id, Item) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br Item = unicode:chardata() .br .RE .RE .LP .nf .B prependCheckItem(This, Id, Item, Options :: [Option]) -> .B wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br Item = unicode:chardata() .br Option = {help, unicode:chardata()} .br .RE .RE .RS .LP Inserts a checkable item at position 0\&. .LP See: \fIprepend/5\fR\&, \fIappendCheckItem/4\fR\& .RE .LP .nf .B prependRadioItem(This, Id, Item) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br Item = unicode:chardata() .br .RE .RE .LP .nf .B prependRadioItem(This, Id, Item, Options :: [Option]) -> .B wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br Item = unicode:chardata() .br Option = {help, unicode:chardata()} .br .RE .RE .RS .LP Inserts a radio item at position 0\&. .LP See: \fIprepend/5\fR\&, \fIappendRadioItem/4\fR\& .RE .LP .nf .B prependSeparator(This) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br .RE .RE .RS .LP Inserts a separator at position 0\&. .LP See: \fIprepend/5\fR\&, \fIappendSeparator/1\fR\& .RE .LP .nf .B remove(This, Id) -> wxMenuItem:wxMenuItem() .br .fi .br .nf .B remove(This, Item) -> wxMenuItem:wxMenuItem() .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Item = wxMenuItem:wxMenuItem() .br .RE .RE .RS .LP Removes the menu item from the menu but doesn\&'t delete the associated C++ object\&. .LP This allows you to reuse the same item later by adding it back to the menu (especially useful with submenus)\&. .LP Return: A pointer to the item which was detached from the menu\&. .RE .LP .nf .B setHelpString(This, Id, HelpString) -> ok .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br HelpString = unicode:chardata() .br .RE .RE .RS .LP Sets an item\&'s help string\&. .LP See: \fIgetHelpString/2\fR\& .RE .LP .nf .B setLabel(This, Id, Label) -> ok .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Id = integer() .br Label = unicode:chardata() .br .RE .RE .RS .LP Sets the label of a menu item\&. .LP See: \fIappend/5\fR\&, \fIgetLabel/2\fR\& .RE .LP .nf .B setTitle(This, Title) -> ok .br .fi .br .RS .LP Types: .RS 3 This = wxMenu() .br Title = unicode:chardata() .br .RE .RE .RS .LP Sets the title of the menu\&. .LP Remark: Notice that you can only call this method directly for the popup menus, to change the title of a menu that is part of a menu bar you need to use \fIwxMenuBar:setLabelTop/3\fR\&\&. .LP See: \fIgetTitle/1\fR\& .RE