Reference Manual - Table of Contents

Execution Control
Forms and Windows
Controls
Menus
System and Desktop
Graphic Drawing Commands

Animation
QuickTime Movies
Speech
Sound
File I/O
Printing
Serial Ports

Math Functions
String Functions
Date and Time
Memory Buffers
Error Handling
Console Text Window

Events

Direct Memory Access
Direct Mouse Access
Direct Keyboard Access
Code Resource Modules

A - Runtime Error Messages
B - Compiler Error Messages

Menus

This section describes commands and functions for creating pulldown menus for the menubar. Items created in the menu bar can be pointed to SUB Procedures, that will be called when this item is selected by the user.

Visual MacStandardBasic automatically creates a menu template (stationary) when a New Project is created. The commands creating this menu template are in a Sub Procedure in Form1 called CreateMyMenus. You can change this procedure to your desired application's menu.

Command Summary:
MenuAdd menu
#, title$, Sub
MenuAddItem menu#, text$, cmdLetter$, Sub
MenuApple
MenuBlank
MenuClear
MenuDelete
menu#
MenuDeleteItem menu#, menuitem#
MenuDesk
MenuDisable
menu#, menuitem#
MenuEnable menu#, menuitem#
MenuFonts menu#
MenuInsertItem menu#, menuitem#, text$, cmdLetter$, Sub
MenuMark menu#, menuitem#, mark
MenuRedraw
MenuText
menu#, menuitem#, text$
SubMenu var, menu#, menuItem#, Sub

Function Summary:
var = MenuCount ( menu# )
var = MenuMark ( menu#, menuitem# )
var$ = MenuText ( menu#, menuitem# )

 

MenuAdd menu#, title$, Sub

This command will add a pull-down menu to the menubar. The value of 1 is for the Apple Menu (use the AppleMenu command to add this menu), 2 for next menu (which is normally a File menu), and so on.

Example:

' Let's create some simple menus
MenuApple
MenuAddItem 1, "About Program", "", AboutMyProgram
MenuDesk 'Append on the rest of Apple Menu stuff
MenuAdd 2, "File", None
MenuAddItem 2, "Quit", "Q", QuitMyApp

 

MenuAddItem menu#, text$, cmdLetter$, Sub

This command will add a menu item to the specified pull-down menu.

Example:

' Let's create some simple menus
MenuApple
MenuAddItem 1, "About Program", "", AboutMyProgram
MenuDesk 'Append on the rest of Apple Menu stuff
MenuAdd 2, "File", None
' The letter O will be the command key for the Open menu item
MenuAddItem 2, "Open", "O", OpenMyFile
MenuAddItem 2, "-", "", None ' Adds a separator line
' The letter Q will be the command key for the Quit menu item
MenuAddItem 2, "Quit", "Q", QuitMyApp

 

MenuApple

This command creates a Apple menu in the first menubar position. The menubar should have no menus when this command is used. You can use the MenuClear command to empty the menubar of menus. Many programmers add an About … menu item to allow the displaying of a copyright information box. Use the MenuDesk command after this to add Desk Accessory Menu folder items that will be appended to your Apple Menu.

 

MenuBlank

This command will blank the menubar but will not remove the menus from the menubar.

 

MenuClear

This command removes all current menus from the menu bar. This includes all submenus that were created.

 

MenuDelete menu#

This command will remove a menu from the menubar.

MenuDeleteItem menu#, menuitem#

This command will remove a menu item from the specified menu.

 

MenuDesk

This command adds the items from the System’s Menu Folder to an Apple Menu. Use this command after you have created an Apple Menu.

 

MenuDisable menu#, menuitem#

This command will disable a menuitem in the specified menu.

MenuEnable menu#, menuitem#

This command will enable a menu item in the specified menu.

MenuFonts menu#

This command will adds a list all fonts available to the the specified menu. The number of font names added with depend on how many fonts are available on the Macintosh the runtime application is run on.

 

MenuInsertItem menu#, menuItem#, text$, cmdLetter$, Sub

This command will insert a menu item at a specified position to the specified menu. All other menu items greater than and equal to the menuItem# will be pushed down one position.

MenuMark menu#, menuItem#, mark

This command will allow you to set or remove a character as the item mark of the specified menu item. Item marks such as a check mark, bullet, diamond, apple, etc… can be used to designate a status of a menu item.

Some common values for mark

0 = No mark
17 = Keyboard command key symbol
18 = Checkmark
19 = Diamond
20 = Apple symbol
165 = Bullet dot
195 = Square root mark
200 = >>
215 = Hollow diamond

 

MenuRedraw

This command will immediately redraw the menubar.

 

MenuText menu#, menuItem#, text$

This command will allow you to change the text of an existing menu item.

SubMenu var, menu#, menuItem#, Sub

This command will insert a sub-menu to a specified menu item position to the menu. Sub-menus are part of the hierarchical menu system, that allows for an entire menu to be attached to a menu item from another menu.

var = MenuCount( menu# )

This function returns the value that indicates how many menu items there are in the specified menu.

var = MenuMark( menu#, menuItem# )

This function returns the value of a item mark of the specified menu item. Item marks such as a check mark, bullet, diamond, apple, etc… can be used to designate a status of a menu item.

Some return values
0 = No mark
17 = Keyboard command key symbol
18 = Checkmark
19 = Diamond
20 = Apple symbol
165 = Bullet dot
195 = Square root mark
200 = >>
215 = Hollow diamond

 

var$ = MenuText( menu#, menuItem# )

This returns a text string value that represents the text of an existing menu item.