Chapter 7. Interface Builder: Menus

Every Carbon application must support menus—the standard ones supplied by Mac OS X and those your application provides. Menus allow users to view or choose from a list of choices any commands or attributes provided by your application. You can add application-specific menus and customize many of the standard menu items to suit your application’s needs.

The easiest way to create, display, and set up the behavior of pull-down, hierarchical, and contextual menus is to use Interface Builder. It provides you with a menu bar that’s already loaded with the standard menus and items. To set up the menus for your application, do the following steps:

  1. Modify the default menu bar by:

    • Disabling the items your application doesn’t need

    • Preparing the items your application needs

    • Adding application-specific menus and menu items

  2. Add code to your project to:

    • Call Interface Builder Services to create the menu bar from the nib file

    • Process the menu commands

In this chapter, you’ll:

  • Look at a typical menu bar for an application running on Mac OS X

  • Go through the menu bar provided by Interface Builder to see which items are set up for you and which ones you need to prepare

  • Discuss hierarchical and contextual menus

  • Modify the menu bar for the Moon Travel Planner application

The Menu Bar

The Mac OS has a menu bar with a number of standard menus and menu items that should appear in any application. Figure 7.1 shows the menu bar for the Finder on Mac OS X. The Apple menu on the ...

Get Learning Carbon now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.