MenuItem()
Syntax
MenuItem(MenuItemID, Text$ [, ImageID])Description
Creates a new item on the menu specified by MenuItemID. In the Text$ argument, you can use the special '&' character to underline a specific letter:
"&File" will actually display: File
To have a keyboard shortcut (will be activated with the AddKeyboardShortcut() function) aligned to the right side of the menu (for example, "Save Ctrl+S") use the tab character to give the correct space. The tab character has an ASCII code of 9 so use the function Chr() with the number 9 to insert a tab character. The code may look something like this:MenuItem(1, "&Open" + Chr(9) + "Ctrl+O")'ImageID' is optional and specify which image will be used for this menu item. The menu has to be created with CreateImageMenu() or CreatePopupImageMenu(). 'ImageID' can be obtained with the ImageID() function from the Image library.
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 EndIfMacOS 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 in the current menu, 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