wxMenuBar(3erl)

πŸ’… wxMenuBar (the 3erl Erlang module definition, bestie)

Okay so picture this: it's the Erlang module definition for wxMenuBar, straight out of the wxWidgets crew. This page?? Genuinely iconic. Let's get into it 🫢


✨ NAME ✨

wxMenuBar β€” literally just the functions for the wxMenuBar class. That's it, that's the vibe. πŸŽ€


🌸 DESCRIPTION 🌸

A menu bar is a series of menus accessible from the top of a frame. Main character energy, sitting up there at the top of your window. πŸ‘‘

Remark: to respond to a menu selection, provide a handler for EVT_MENU, in the frame that contains the menu bar. Like, the frame is the one holding the bag here, not the bar itself. πŸ’…

Also lowkey important: if you have a toolbar which uses the same identifiers as your EVT_MENU entries, events from the toolbar will also be processed by your EVT_MENU event handlers. Not a bug, just how it is, no cap.

Tip: under Windows, if you discover that menu shortcuts (for example, Alt-F to show the file menu) are not working, check any EVT_CHAR events you are handling in child windows. If you are not calling event.Skip() for events that you don't process in these event handlers, menu shortcuts may cease to work. Genuinely a trap, bestie β€” don't let it happen to you 😭

See: wxMenu, Overview events

This class is derived (and can use functions) from: wxWindow, wxEvtHandler β€” so it's got that whole family tree going on 🌈

wxWidgets docs: wxMenuBar


πŸ¦‹ DATA TYPES πŸ¦‹

wxMenuBar() = wx:wx_object()

Simple. Clean. Slay. ✨


πŸ’œ EXPORTS πŸ’œ

  • new() -> wxMenuBar() β€” construct an empty menu bar. A blank canvas, an empty group chat, a fresh start πŸŽ€
  • new(Style) -> wxMenuBar() β€” the same thing but with style, obviously.
    • Types:
      • Style = integer()
  • destroy(This :: wxMenuBar()) -> ok β€” destructor, destroying the menu bar and removing it from the parent frame (if any). It's giving closure, honestly πŸ’€
  • append(This, Menu, Title) -> boolean() β€” adds the item to the end of the menu bar.
    • Types:
      • This = wxMenuBar()
      • Menu = wxMenu:wxMenu()
      • Title = unicode:chardata()
    • Return: true on success, false if an error occurred.
    • See: insert/4
  • check(This, Id, Check) -> ok β€” checks or unchecks a menu item.
    • Types:
      • This = wxMenuBar()
      • Id = integer()
      • Check = boolean()
    • > Remark: only use this when the menu bar has been associated with a frame; otherwise, use the wxMenu equivalent call. Fr fr, read the room 😌
  • enable(This, Id, Enable) -> ok β€” enables or disables (greys out) a menu item. The greying out is so real.
    • Types:
      • This = wxMenuBar()
      • Id = integer()
      • Enable = boolean()
    • > Remark: only use this when the menu bar has been associated with a frame; otherwise, use the wxMenu equivalent call.
  • enableTop(This, Pos, Enable) -> ok β€” enables or disables a whole menu. All of it. Wholesale.
    • Types:
      • This = wxMenuBar()
      • Pos = integer()
      • Enable = boolean()
    • > Remark: only use this when the menu bar has been associated with a frame.
  • findMenu(This, Title) -> integer() β€” returns the index of the menu with the given title or wxNOT_FOUND if no such menu exists in this menubar.
    • Types:
      • This = wxMenuBar()
      • Title = unicode:chardata()
    • The Title parameter may specify either the menu title (with accelerator characters, i.e. "&File") or just the menu label ("File") indifferently. Flexible queen πŸ’…
  • findMenuItem(This, MenuString, ItemString) -> integer() β€” finds the menu item id for a menu name/menu item string pair.
    • Types:
      • This = wxMenuBar()
      • MenuString = ItemString = unicode:chardata()
    • Return: the menu item identifier, or wxNOT_FOUND if none was found.
    • > Remark: any special menu codes are stripped out of source and target strings before matching. Sneaky but fair 🧚
  • findItem(This, Id) -> wxMenuItem:wxMenuItem() β€” finds the menu item object associated with the given menu item identifier.
    • Types:
      • This = wxMenuBar()
      • Id = integer()
    • Return: the found menu item object, or NULL if one was not found.
  • getHelpString(This, Id) -> unicode:charlist() β€” gets the help string associated with the menu item identifier.
    • Types:
      • This = wxMenuBar()
      • Id = integer()
    • Return: the help string, or the empty string if there was no help string or the menu item was not found.
    • See: setHelpString/3
  • getLabel(This, Id) -> unicode:charlist() β€” gets the label associated with a menu item.
    • Types:
      • This = wxMenuBar()
      • Id = integer()
    • Return: the menu item label, or the empty string if the item was not found.
    • > Remark: use only after the menubar has been associated with a frame.
  • getLabelTop(This, Pos) -> unicode:charlist() β€” see getMenuLabel/2. That's the whole description, she's mysterious πŸ’…
    • Types:
      • This = wxMenuBar()
      • Pos = integer()
  • getMenuLabel(This, Pos) -> unicode:charlist() β€” returns the label of a top-level menu.
    • Types:
      • This = wxMenuBar()
      • Pos = integer()
    • Note that the returned string includes the accelerator characters that have been specified in the menu title string during its construction.
    • Return: the menu label, or the empty string if the menu was not found.
    • > Remark: use only after the menubar has been associated with a frame.
    • See: getMenuLabelText/2, setMenuLabel/3
  • getMenuLabelText(This, Pos) -> unicode:charlist() β€” returns the label of a top-level menu.
    • Types:
      • This = wxMenuBar()
      • Pos = integer()
    • Note that the returned string does not include any accelerator characters that may have been specified in the menu title string during its construction. (Yes, this is the opposite of getMenuLabel/2. They're sisters, not twins 🫢)
    • Return: the menu label, or the empty string if the menu was not found.
    • > Remark: use only after the menubar has been associated with a frame.
    • See: getMenuLabel/2, setMenuLabel/3
  • getMenu(This, MenuIndex) -> wxMenu:wxMenu() β€” returns the menu at MenuIndex (zero-based). Zero-based indexing, my beloved 😭
    • Types:
      • This = wxMenuBar()
      • MenuIndex = integer()
  • getMenuCount(This) -> integer() β€” returns the number of menus in this menubar. Counting is self care ✨
    • Types:
      • This = wxMenuBar()
  • insert(This, Pos, Menu, Title) -> boolean() β€” inserts the menu at the given position into the menu bar.
    • Types:
      • This = wxMenuBar()
      • Pos = integer()
      • Menu = wxMenu:wxMenu()
      • Title = unicode:chardata()
    • Inserting menu at position 0 will insert it in the very beginning of it, inserting at position getMenuCount/1 is the same as calling append/3. So like, the edges are the same edges πŸ‘‘
    • Return: true on success, false if an error occurred.
    • See: append/3
  • isChecked(This, Id) -> boolean() β€” determines whether an item is checked.
    • Types:
      • This = wxMenuBar()
      • Id = integer()
    • Return: true if the item was found and is checked, false otherwise.
  • setAutoWindowMenu(Enable) -> ok β€” sets the auto window menu. No further notes, she's concise.
    • Types:
      • Enable = boolean()
  • getAutoWindowMenu() -> boolean() β€” gets the auto window menu. Also concise. Matching set πŸŽ€
  • oSXGetAppleMenu(This) -> wxMenu:wxMenu() β€” returns the Apple menu.
    • Types:
      • This = wxMenuBar()
    • This is the leftmost menu with application's name as its title. You shouldn't remove any items from it, but it is safe to insert extra menu items or submenus into it. Respect her boundaries and she'll respect yours πŸ“
    • Only for: wxosx
    • Since: 3.0.1
  • macGetCommonMenuBar() -> wxMenuBar() β€” enables you to get the global menubar on Mac, that is, the menubar displayed when the app is running without any frames open.
    • Return: the global menubar.
    • > Remark: only exists on Mac, other platforms do not have this method. Sorry to everyone else πŸ’€
    • Only for: wxosx
  • macSetCommonMenuBar(Menubar) -> ok β€” enables you to set the global menubar on Mac, that is, the menubar displayed when the app is running without any frames open.
    • Types:
      • Menubar = wxMenuBar()
    • > Remark: only exists on Mac, other platforms do not have this method. Again. Mac exclusive 🧚
    • Only for: wxosx
  • isEnabled(This, Id) -> boolean() β€” determines whether an item is enabled.
    • Types:
      • This = wxMenuBar()
      • Id = integer()
    • Return: true if the item was found and is enabled, false otherwise.
  • remove(This, Pos) -> wxMenu:wxMenu() β€” removes the menu from the menu bar and returns the menu object β€” the caller is responsible for deleting it. Yes, you. It's your problem now πŸ™ˆ
    • Types:
      • This = wxMenuBar()
      • Pos = integer()
    • This function may be used together with insert/4 to change the menubar dynamically. Glow-up in real time πŸ’«
    • See: replace/4
  • replace(This, Pos, Menu, Title) -> wxMenu:wxMenu() β€” replaces the menu at the given position with another one. Out with the old, in with the new.
    • Types:
      • This = wxMenuBar()
      • Pos = integer()
      • Menu = wxMenu:wxMenu()
      • Title = unicode:chardata()
    • Return: the menu which was previously at position pos. The caller is responsible for deleting it. Same deal as remove/2, bestie 🫢
    • See: insert/4, remove/2
  • setHelpString(This, Id, HelpString) -> ok β€” sets the help string associated with a menu item.
    • Types:
      • This = wxMenuBar()
      • Id = integer()
      • HelpString = unicode:chardata()
    • See: getHelpString/2
  • setLabel(This, Id, Label) -> ok β€” sets the label of a menu item.
    • Types:
      • This = wxMenuBar()
      • Id = integer()
      • Label = unicode:chardata()
    • > Remark: use only after the menubar has been associated with a frame.
    • See: getLabel/2
  • setLabelTop(This, Pos, Label) -> ok β€” see setMenuLabel/3. Short and sweet πŸ’…
    • Types:
      • This = wxMenuBar()
      • Pos = integer()
      • Label = unicode:chardata()
  • setMenuLabel(This, Pos, Label) -> ok β€” sets the label of a top-level menu.
    • Types:
      • This = wxMenuBar()
      • Pos = integer()
      • Label = unicode:chardata()
    • > Remark: use only after the menubar has been associated with a frame.

And that's the whole page, bestie β€” no skips, no cap, every flag accounted for πŸ’–

Later, babes ✌️ β€” this one's brought to you by the wxWidgets team, running wx 2.2.2.1, and it's the wxMenuBar(3erl) page, mwah πŸ’‹

πŸ“¦ where this page comes from