Important: The information in this document is obsolete and should not be used for new development.
Using the Menu Manager
You can define your application's menus and menu bar as resources and use Menu Manager routines to create and manage them. For example, whenever the user presses the mouse button while the cursor is in the menu bar, your application should call theMenuSelect
function, allowing the user to choose a command from any menu. TheMenuSelect
function handles all user activity until the user releases the mouse button. TheMenuSelect
function displays and removes menus as the user drags the cursor through the menu bar, and it highlights enabled menu items as the user drags through
a menu.You should provide help balloons for each menu title and menu item of your application. You store information and text for help balloons in resources. See the chapter
"Help Manager" in Inside Macintosh: More Macintosh Toolbox for complete and specific
information on how to provide help balloons for the menus of your application. The
BalloonWriter application, available from APDA, can also help you create help balloons for the menus of your application.Your application needs to initialize QuickDraw, the Font Manager, and the Window Manager before using the Menu Manager. Your application can accomplish this using the
InitGraf
,InitFonts
, andInitWindows
procedures. To initialize the Menu Manager, use theInitMenus
procedure.If your application uses pop-up menus, use the
Gestalt
function with thegestaltPopUpAttr
selector to determine if the control definition function for
pop-up menus is available. See Inside Macintosh: Operating System Utilities for information about theGestalt
function.To create the pull-down menus in your application's menu bar, you need to
The next section, "Creating a Menu," explains these steps in detail.
- create descriptions of each pull-down menu in
'MENU'
resources- create an
'MBAR'
resource that lists the order and resource ID of each menu- use the
GetNewMBar
function andSetMenuBar
procedure to set up your menu bar and use theDrawMenuBar
procedure to draw your menu bar
After creating your application's menu bar, you can enable or disable your menu items, add marks such as checkmarks or dashes to menu items, or add items to any of your menus as needed. See "Enabling and Disabling Menu Items" on page 3-59, "Changing the Mark of Menu Items" on page 3-63, and "Adding Items to a Menu" beginning on page 3-66 for information on these topics.
"Handling User Choice of a Menu Command," beginning on page 3-72, shows how to handle mouse-down events in the menu bar, adjust the menus of your application, and determine if the user chose a keyboard equivalent of a command.
"Responding When the User Chooses a Menu Item," beginning on page 3-80, describes how your application should respond once the user chooses an item and also shows how to handle the user's choice of a command from the Apple and Help menus.
If your application displays dialog boxes, see "Accessing Menus From a Dialog Box" beginning on page 3-86.
Finally, if your application needs to create submenus or pop-up menus, see "Creating a Hierarchical Menu" on page 3-55 and "Creating a Pop-Up Menu" on page 3-58.
Subtopics
- Creating a Menu
- Creating a Hierarchical Menu
- Creating a Pop-Up Menu
- Changing the Appearance of Items in a Menu
- Adding Items to a Menu
- Handling User Choice of a Menu Command
- Responding When the User Chooses a Menu Item
- Accessing Menus From a Dialog Box
- Writing Your Own Menu Definition Procedure