Home > Articles > Home & Office Computing > Mac OS X

This chapter is from the book

This chapter is from the book

Pull-Down Menus

Menu Definition Functions and Menu Bar Definition Functions

The Menu Manager uses the following to display, and to perform basic operations on, menus and the menu bar:

  • Menu Definition Function. When you define a menu, you must specify the required menu definition function (MDEF). The Menu Manager uses that MDEF to draw the menu items in a menu, determine which item the user chose, and so on. An MDEF thus determines the look and behavior of menus.

  • Menu Bar Definition Function. The Menu Manager uses the menu bar definition function (MBDF) to draw and clear the menu bar, determine whether the cursor is currently within the menu bar or any currently displayed menu, highlight menu titles, and so on. A menu bar definition function thus determines the look and behavior of the menu bar.

Standard Menu and Menu Bar Definition Functions

The system software provides a standard MDEF and a standard MBDF. The standard MDEF is the 'MDEF' resource with a resource ID of 63. The standard MBDF is the 'MBDF' resource with a resource ID of 63.

Ordinarily, your application will specify the standard definition functions; however, as with most other elements of the Macintosh user interface, the option is available to write your own custom definition function if you need to provide features not available in the standard definition functions.

The Menu Bar and Menus

The Menu Bar

The menu bar extends across the top of the screen and is high enough to display menu titles in the height of the large system font (Mac OS 8/9) or system font (Mac OS X).

Generally, the menu bar should always be visible. If you want to hide the menu bar for some reason, you should provide a method (for example, a keyboard equivalent) to allow the user to make the menu bar reappear.

The 'MBAR' Resource

Each application has its own menu bar, which is defined by an 'MBAR' resource. This resource lists the order and resource ID of each menu appearing in your menu bar. Your application's 'MBAR' resource should be defined such that the Mac OS 8/9 Apple menu or Mac OS X Application menu (see below) is the first menu in the menu bar, with the File menu being the next. For Mac OS 8/9, the Help menu and the Mac OS 8/9 Application menu do not need to be defined in the 'MBAR' resource, because the Menu Manager automatically adds them to the menu bar when the application calls GetNewMBar, provided that your menu bar includes the Apple menu.

Menus

All Macintosh applications should ordinarily provide the Mac OS 8/9 Apple menu or Mac OS X Application menu, a File menu, and a Window menu (see Chapter 16). If your application is not document-oriented, the File menu may be renamed to something more appropriate.

Your application can disable any menu, which causes the Menu Manager to dim that menu's title and all associated menu items. The menu items can also be disabled individually. Your application should specify whether menu items are enabled or disabled when it first defines and creates a menu and can enable or disable items at any time thereafter.

The 'MENU' Resource

For each menu, you define the menu title and the individual characteristics of its menu items in a 'MENU' resource.

The 'xmnu' Resource

For each menu, you may also define an 'xmnu' (extended menu) resource. The 'xmnu' resource is, in effect, an extension of the 'MENU' resource required to provide for additional menu features. . Note that you do not need to provide this resource if you do not require these additional features. An 'xmnu' resource must have the same ID as the 'MENU' resource it extends.

Menu Items

A menu item can contain text or a divider. On Mac OS 8/9 the divider is a line extending the full width of the menu. On Mac OS X it is simply an empty space, like a menu item with no text. Each menu item, other than a divider, can have a number of characteristics as follows:

  • An icon, small icon, reduced icon, color icon, or an icon from an icon family to the left of the menu item's text.

  • NOTE

    The various icon types are described in Chapter 13.

  • A checkmark or other marking character indicating the status of the menu item or the mode it controls.

  • The symbols for the item's keyboard equivalent. (An item that has a keyboard equivalent cannot have a submenu, a small icon or a reduced icon.)

  • A triangular indicator to the right of a menu item's text to indicate that the item has a submenu. (An item that has a submenu cannot have a keyboard equivalent, a small icon or a reduced icon.)

  • A font style (bold, italic, and so on) for the menu item's text.

  • The text of the menu item.

  • The ellipsis character (...) as the last character in the text of the menu item, indicating that the application will display a dialog requesting more information from the user before executing the command. (The ellipsis character should not be used in menu items that display informational dialogs or a confirmational alert.)

  • A dimmed appearance when the application disables the item. (When the menu title is dimmed, all menu items in that menu are also dimmed.)

Groups of Menu Items

Where appropriate, menu items should be grouped, with each group separated by a divider. For example, a menu can contain commands that perform actions and commands that set attributes. The action commands that are logically related should be grouped, as should attribute commands that are interdependent. The attribute commands that are mutually exclusive, and those that form accumulating attributes (for example, Bold, Italic and Underline), should also be grouped.

Keyboard Equivalents for Menu Commands

The Menu Manager provides support for keyboard equivalents. Your application can detect a keyboard equivalent by examining the modifiers field of the event structure, first determining whether the Command key was pressed at the time of the event. If a keyboard equivalent is detected, your application typically calls MenuEvent, which maps the keyboard equivalent character contained in the specified event structure to its corresponding menu and menu item and returns the menu ID and the chosen menu item.

NOTE

A keyboard equivalent is any combination of the Command key, optionally one or more modifier keys (Shift, Option, Control), and another key. A Command-key equivalent such as Command-C is thus, by definition, also a keyboard equivalent.

Reserved Command-Key Equivalents

Apple reserves the following Command-key equivalents, which should be used in the File and Edit menus of your application:

Keys

Command

Menu

Command-A

Select All

Edit

Command-C

Copy

Edit

Command-N

New

File

Command-H

Hide <appname>

Application (Mac OS X)

Command-M

Minimize Window

Window (Mac OS X)

Command-O

Open...

File

Command-P

Print...

File

Command-Q

Quit Application (Mac OS X)

File (Mac OS 8/9)

Command-S

Save

File

Command-V

Paste

Edit

Command-W

Close

File

Command-X

Cut

Edit

Command-Z

Undo

Edit


Other common keyboard equivalents are

Keys

Command

Menu

Command-B

Bold

Style

Command-F

Find

File

Command-G

Find Again

File

Command-I

Italic

Style

Command-T

Plain Text

Style

Command-U

Underline

Style


The Mac OS 8/9 Apple Menu and Mac OS X Application Menu

On Mac OS 8/9, the Mac OS 8/9 Apple Menu is the first menu in your application. On Mac OS X, the Mac OS X Application Menu (see Fig 1) is the first menu.

Figure 3.1 MAC OSX application menu

Typically, applications provide an About command as the first menu item in the Apple (Mac OS 8/9) and Mac OS X Application menus. On Mac OS 8/9, the remaining items are controlled by the contents of the Apple Menu Items folder in the System folder. On Mac OS X, the remaining items are the default items automatically included in the system-created Mac OS X Application menu. Mac OS X Application menu items are general to the application, that is, they are items that are not specific to a document or other window.

To create your application's Mac OS 8/9 Apple menu for Mac OS 8/9, you simply define the Apple menu title and the characteristics of your application's About command in a 'MENU' resource. When your application is run on Mac OS 8/9, the contents of the Apple Menu Items folder are automatically added to the Apple menu.

The Apple menu 'MENU' resource will also cause the About command to be inserted in the Mac OS X Application menu when the application is run on Mac OS X.

When the user chooses the About command on Mac OS 8/9, your application should display a dialog or an alert containing your application's name, version number, copyright information, any other information as required. On Mac OS X, your application should display a modeless dialog containing the application's version and copyright information, as prescribed in Aqua Human Interface Guidelines.

The File Menu

The standard File menu contains commands related to document management plus, on Mac OS 8/9, the Quit command. (On Mac OS X, the Quit command is located in the Application menu (refer to Fig 1).) The standard commands should be supported by your application where appropriate (see Fig 2). Any other commands added to the menu should pertain to the management of documents. The actions your application should take when File menu commands are chosen are detailed in Chapter 15 and Chapter 18.

Figure 3.2 The standard file and edit menus

The Edit Menu

The standard Edit menu provides commands related to the editing of a document's contents, to copying data between different applications using the Clipboard and, on Mac OS 8/9, to showing and hiding the Clipboard (refer to Fig 2). For Mac OS 8/9 only, the standard Edit menu also standardizes the location of the Preferences... command, which, when chosen, should invoke a dialog that enables the user to set application-specific preferences. (On Mac OS X, the Preferences... command is located in the Mac OS X Application menu.)

NOTE

The implementation of Preferences commands is demonstrated at the demonstration program in Chapter 19.

All Macintosh applications which support text entry, including text entry in edit text items in dialogs, should include the standard editing commands (Undo, Cut, Copy, Paste and Clear). An additional word or phrase should be added to Undo to clarify exactly what action your application will reverse.

Other commands may be added if they are related to editing or changing the contents of your application's documents.

The Mac OS 8/9 System-Managed Menus

On Mac OS 8/9, two menus, namely the Mac OS 8/9 Application menu and the Help menu, are added automatically by the Menu Manager and are often referred to as the system- managed menus.

The Mac OS 8/9 Application Menu

When the user chooses an item from the Mac OS 8/9 Application menu, the Menu Manager handles the event as appropriate. For example, if the user chooses another application, your application is sent to the background and receives a suspend event.

The Mac OS 8/9 Help Menu

Applications written for Mac OS 8/9 using the Classic API have the option of programmatically appending an item (or items) to the end of the Help menu, and of programmatically detecting the user's choice of that item, so as to give the user access to help texts provided by the application. This option is not available in the Carbon API.

Carbon applications may use Apple Help, which was introduced with Mac OS 8.6, to provide application help. Apple Help documentation and tools are included in an Apple Help Software Development Kit (SDK), which is available at http://developer.apple.com/sdk. The documentation describes how to create an Apple Guide file, which, when located in the same folder as your application, will cause the system to install a help menu item (or items) in the Help menu. The menu at the left in Fig 3 show the Help menu as it normally appears. The menus at the right at Fig 3 show the Help menu as it appears when the Apple Guide file is present.

Figure 3.3 The MAC OS help menu - effect of the Apple guide file.

Mac OS Help Menus

For Mac OS X, your application must itself create the Help menu (using the function HMGetHelpMenu), insert the required item, or items, in that menu, and respond to the user choosing items in the menu.

Font Menus

If your application has a Font menu, you should list in that menu the names of all currently available fonts (that is, all those residing in the Fonts folder in the System folder). Fonts may be added to the Font menu using AppendResMenu or InsertResMenu. However, a better alternative is to use the relatively new Menu Manager function CreateStandardFontMenu to build either a hierarchical or non-hierarchical Font menu. (A hierarchical Font menu is one in which the styles available in each font family (regular, bold, italic, and so on) appear in a submenu attached to the menu item containing the font family name.)

To indicate which font is currently in use in a non-hierachical Font menu, your application should add a checkmark to the left of the font's name in the Font menu. If the current selection contains more than one font, a dash should be placed next to the name of each font the selection contains. When the user starts entering text at the insertion point, your application should display text in the current font.

To indicate which font is currently in use in a hierachical Font menu, your application should place a checkmark next to the font in the submenu and a dash next to the menu item to which the submenu is attached.

Font Attributes

Separate menus should be used to accommodate lists of font attributes such as styles and sizes.

WYSIWYG Font Menus

The function SetMenuItemFontID allows you to easily set up a Font menu with each item being drawn in the actual font.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020