Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Macintosh Toolbox Essentials /
Chapter 3 - Menu Manager / Menu Manager Reference
Menu Manager Routines / Adding and Deleting Menu Items


AppendMenu

Use the AppendMenu procedure to append one or more items to a menu previously created using NewMenu, GetMenu, or GetNewMBar.

PROCEDURE AppendMenu (menu: MenuHandle; data: Str255); 
menu
A handle to the menu record of the menu to which you wish to append the menu item or items.
data
A string that defines the characteristics of the new menu item or items. Note that in most cases you should store the text of a menu item in a resource, so that your menu items can be more easily localized. The AppendMenu procedure appends the menu items in the order in which they are listed in the data parameter.
DESCRIPTION
The AppendMenu procedure appends any defined menu items to the specified menu. The menu items are added to the end of the menu. You specify the text of any menu items and their characteristics in the data parameter. You can embed metacharacters in the string to define various characteristics of a menu item.

Here are the metacharacters that you can specify in the data parameter:
MetacharacterDescription
; or ReturnSeparates menu items.
^When followed by an icon number, defines the icon for the item. If the keyboard equivalent field contains $1C, this number is interpreted as a script code.
!When followed by a character, defines the mark for the item. If the keyboard equivalent field contains $1B, this value is interpreted as
the menu ID of a submenu of this menu item.
<When followed by one or more of the characters B, I, U, O, and S, defines the character style of the item to Bold, Italic, Underline, Outline, or Shadow, respectively.
/When followed by a character, defines the keyboard equivalent for the item. When followed by $1B, specifies that this menu item has a submenu. To specify that the menu item has a script code, small icon, or reduced icon, use the SetItemCmd procedure to set the keyboard equivalent field to $1C, $1D, or $1E, respectively.
(Defines the menu item as disabled.

You can specify any, all, or none of these metacharacters in the text string. The metacharacters that you specify aren't displayed in the menu item. (To use any of these metacharacters in the text of a menu item, first use AppendMenu, specifying at least one character as the item's text, and then use the SetMenuItemText procedure to set the item's text to the desired string.)

Note
If you add menu items using the AppendMenu procedure, you should define the text and any marks or keyboard equivalents in resources for easier localization.
You can specify the first character that defines the text of a menu item as a hyphen to create a divider line. The string in the data parameter can be blank (containing one or more spaces), but it should not be an empty string.

If you do not define a specific characteristic of a menu item, the AppendMenu procedure assigns the default characteristic to the menu item. If you do not define any characteristic other than the text for a menu item, the AppendMenu procedure inserts the menu item so that it appears in the menu as an enabled item, without an icon or a mark, in the plain character style, and without a keyboard equivalent.

You can use AppendMenu to append items to a menu regardless of whether the menu is in the current menu list.

SEE ALSO
See "Adding Items to a Menu" on page 3-64 for examples of appending items to a menu.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 JUL 1996