MenuItem()

Syntax

MenuItem(MenuItemID, Text$)
Description
Creates a new item entry for the menu. In the Text$, you can use the special '&' character to underline a specific letter:

"&File" will give in reality : File

If you want to have a keyboard shortcut (will be activated with the AddKeyboardShortcut() command) aligned to the right side of the menu (for example, "Save Ctrl+S") then you can use the tab character to give you the correct space. The tab character has an ASCII code of 9 so you would use the command Chr() with the number 9 to insert a tab character. Your code may look something like this:
MenuItem(1, "&Open" + Chr(9) + "Ctrl+O")

Example:
  If OpenWindow(0, 200, 200, 200, 100, "MenuItem Example")
    If CreateMenu(0, WindowID(0))
      MenuTitle("Project")
        MenuItem(1, "Open")    ; normal item
        MenuItem(2, "&Save")   ; item with underlined character, the underline will only
                               ; be displayed, if menu is called with F10 + arrow keys
        MenuItem(3, "Quit"+Chr(9)+"Esc")   ; item with separate shortcut text
    EndIf
    Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
  EndIf
MacOS X: the 'Quit', 'Preferences' and 'About' items are considered as specials and need to be placed in the 'Application' menu to have the look'n'feel of OS X applications. PureBasic support the #PB_Menu_Quit, #PB_Menu_Preferences and #PB_Menu_About constants (to be specified as the 'MenuItemID') for these kind of menu items. When one of these constants is detected, the item isn't inserted at the current place, but in the 'Application' menu. If a shortcut was specified, it is simply ignored and replaced by the standard one. These 3 constants aren't defined on others OS, to allow flexible numbering on these OS.

Supported OS

All

<- MenuID() - Menu Index - MenuTitle() ->