MenuItem()

Syntax

MenuItem(MenuItemID, Text$ [, ImageID])
Description
Creates a new item on the current menu.

Parameters

MenuItemID A number to identify this menu item. This value should be between 0 and 65535.
Text$ The text for the menu item. The special '&' character to underline a specific letter:

"&File" will actually display: File
ImageID (optional) The image to be displayed next to the menu item. The menu must be created with CreateImageMenu() or CreatePopupImageMenu() for the image to be displayed. This value can be obtained using the ImageID() function.

Return value

None.

Remarks

To have a keyboard shortcut aligned to the right side of the menu (for example, "Save Ctrl+S") use the tab character (#TAB$ or Chr(9)) to give the correct space. The code may look something like this:
  MenuItem(1, "&Open" + #TAB$ + "Ctrl+O")
The supported modifiers are:
  - "Ctrl"  : Control key
  - "Shift" : Shift key
  - "Alt"   : Alt key
They can be mixed together with the "+" character: "Save As" + #TAB$ + "Ctrl+Shift+S".

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" + #TAB$ + "Shift+Q")   ; item with separate shortcut text
    EndIf
  EndIf

See Also

MenuTitle(), MenuBar(), OpenSubMenu()

Supported OS

All

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