Important: The information in this document is obsolete and should not be used for new development.
Chapter 3 - Menu Manager
You can use the Menu Manager to create and manage the menus in your application. Menus allow the user to view or choose from a list of choices and commands that your application provides.All Macintosh applications should provide these standard menus: the Apple menu, the File menu, and the Edit menu. If you include an Apple menu as a menu of your application, the Menu Manager automatically adds the Help and Application menus to your application's menu bar; it adds the Keyboard menu if more than one keyboard layout or input method is installed.
Menus are typically stored as resources. This chapter describes the menu-related resources. See the chapter "Introduction to the Macintosh Toolbox" in this book for general information on resources and see the chapter "Resource Manager" in Inside Macintosh: More Macintosh Toolbox for information on Resource Manager routines.
See Macintosh Human Interface Guidelines for additional examples of menus that incorporate many principles of user interface design. Inside Macintosh: Text contains further information on localizing your application for worldwide markets.You can choose to provide help balloons for your application's menus. See the chapter "Help Manager" in Inside Macintosh: More Macintosh Toolbox for additional details on providing help balloons for your application's menus.
You often present a dialog box to the user as a result of the user's choice of a menu command that requires additional information before you can perform the command. See the chapter "Dialog Manager" later in this book for information on creating dialog boxes in your application.
For additional information on processing events, see the chapter "Event Manager" earlier in this book.
This chapter provides an introduction to menus and the menu bar, and it then describes
- various types of menus your application can use
- standard menus
- how to store menus as resources
- how to create menus
- how to create a menu bar
- how to change characteristics of menu items
- how to add items to a menu
Chapter Contents
- Introduction to Menus
- Menu and Menu Bar Definition Routines
- The Menu Bar
- Menus
- Menu Items
- Groups of Menu Items
- Keyboard Equivalents for Menu Commands
- Menus Added Automatically by the Menu Manager
- The Apple Menu
- The File Menu
- The Edit Menu
- The Font Menu
- The Size Menu
- The Help Menu
- The Keyboard Menu
- The Application Menu
- Pop-Up Menus
- Hierarchical Menus
- About the Menu Manager
- How the Menu Manager Maintains Information About Menus
- How the Menu Manager Maintains Information About an Application's Menu Bar
- Using the Menu Manager
- Creating a Menu
- Creating a Menu Resource
- Creating a Menu Bar Resource
- Setting Up Your Application's Menu Bar
- Creating a Hierarchical Menu
- Creating a Pop-Up Menu
- Changing the Appearance of Items in a Menu
- Enabling and Disabling Menu Items
- Changing the Text of an Item
- Changing the Font Style of Menu Items
- Changing the Mark of Menu Items
- Changing the Icon or Script Code of Menu Items
- Adding Items to a Menu
- Adding Items to the Help Menu
- Adding Items to the Apple Menu
- Adding Fonts to a Menu
- Handling User Choice of a Menu Command
- Handling Mouse-Down Events in the Menu Bar
- Adjusting the Menus of an Application
- Determining if the User Chose a Keyboard Equivalent
- Responding When the User Chooses a Menu Item
- Handling the Apple Menu
- Handling the Help Menu
- Handling a Size Menu
- Accessing Menus From a Dialog Box
- Writing Your Own Menu Definition Procedure
- Calculating the Dimensions of a Menu
- Drawing Menu Items in a Menu
- Determining Whether the Cursor Is in an Enabled Menu Item
- Menu Manager Reference
- Data Structures
- The Menu Record
- The Menu List
- The Menu Color Information Table Record
- Menu Manager Routines
- Initializing the Menu Manager
- Creating Menus
- Adding Menus to and Removing Menus From the Current Menu List
- Getting a Menu Bar Description From an 'MBAR' Resource
- Getting and Setting the Menu Bar
- Drawing the Menu Bar
- Responding to the User's Choice of a Menu Command
- Getting a Handle to a Menu Record
- Adding and Deleting Menu Items
- Getting and Setting the Appearance of Menu Items
- Disposing of Menus
- Counting the Items in a Menu
- Highlighting the Menu Bar
- Recalculating Menu Dimensions
- Managing Entries in the Menu Color Information Table
- Application-Defined Routine
- The Menu Definition Procedure
- Resources
- The Menu Resource
- The Menu Bar Resource
- The Menu Color Information Table Resource
- The Menu Definition Procedure Resource
- Summary of the Menu Manager
- Pascal Summary
- Constants
- Data Types
- Menu Manager Routines
- Application-Defined Routine
- C Summary
- Constants
- Data Types
- Menu Manager Routines
- Application-Defined Routine
- Assembly-Language Summary
- Data Structures
- Global Variables
- Result Codes