Common Desktop Environment: Application Builder User's Guide

Creating and Editing Menus

A menu is a list of items with meaningful labels. Each item is connected to a function which is performed when the menu is displayed and the item is selected. This section explains how to create and edit menus, how to attach menus to objects, and how to connect menu items to programmatic functions.

Menus can be attached to menu buttons, menubar items, lists, and any of the four types of panes. A menu is automatically attached to an option menu, so there is no need to attach a menu to it.

Menu Property Editor

The Menu Property Editor is used to create menus. A menu, unlike most of the objects edited in the Revolving Property Editor, is a created object and is not available from the object palettes.

Only properties unique to a menu object are described here. See "Property Editor: Universal Properties" for descriptions of Object Type, Objects, Object Name, and Color. See "Property Editor: Common Properties" for descriptions of Items, Label, and Item State (Active).

Add New Menu

Adds a new menu to the list of menus.

Edit

Performs edit functions (Cut, Copy, Paste, Delete) on the selected item in the list of menu objects. Cut and Copy place the selected item in a buffer, ready for Paste. Delete removes the item, but does not place it in a buffer.

Tearoff

Specifies whether tearoff is Enabled or Disabled. If tearoff is enabled the selected menu will be "postable." That is, the menu will be displayed until you explicitly dismiss it if you click on the Tearoff indicator (a dotted line).

Item Label Type

Specifies the type of label (String, Graphic, or Separator) for the item selected in the Items list. If Graphic is chosen, Label becomes Graphic Filename. If Separator is chosen, Label or Graphic Filename becomes inactive and Line Style becomes active. A Separator menu item is used to create a visual division in a menu, such as that seen in the Editors menu of the App Builder primary window.

Item Mnemonic

Specifies one of the letters in the selected item as a keyboard shortcut for choosing the item when the menu is posted. The letter specified will be underlined. Pressing the mnemonic letter when the menu is posted causes that item to be chosen. Note that case is significant and that a particular letter can be used as a mnemonic only once within a menu.

Accelerator

Specifies a keyboard shortcut for choosing the selected item. An accelerator is comprised of a prefix (Ctrl, Alt, Meta, or Shift), <Key>, and a letter (uppercase or lowercase). To make Control-x an accelerator, for instance, type the following:

Ctrl<Key>x

When you display the menu in test mode or in the compiled application, Ctrl+x will be included to the right of the menu item label. If you press the Control key and type x with focus in the window that contains the menu, the action specified in the menu item will be performed.

You can combine the Shift key with one of the other keys to form a compound prefix, if you wish. To make Shift Control-x an accelerator, type the following:

Shift Ctrl<Key>x

Line Style

Specifies the type of line style for the selected separator item; active only when Item Label Type is Separator. Choices are None, Etched In, Etched Out, Etched In Dash, Etched Out Dash, Single Line, Double Line, Single Dashed Line, and Double Dashed Line. A separator of the chosen line style will be displayed in the menu instead of a graphic or text label.

Item SubMenu

A menu button and a text field for attaching, de-attaching, creating, or editing a submenu for the selected item in the Items list. If a submenu is attached to the selected item, the name of the submenu will be displayed in the text field. Not valid for separator item type.

To Create a Menu

This description assumes you are creating a menu and attaching it to an interface object as two separate procedures. To combine these procedures, see "To Create and Attach a Menu " .


Note -

Menus are available within modules only. Be sure the menu created is in the same module as the object you wish to attach the menu to. Menus are created in the current module, which is determined by what is selected in the interface. The Editing Module field in the object information area of the App Builder primary window indicates the current module.


  1. Display the Menu Property Editor by choosing Menus from the Editors menu in the App Builder primary window.

    Or, display the Revolving Property Editor and choose Menu as the Object Type.

    Choosing Menus from the Editors menu in the primary window is the same as clicking the Tear-off button in the Revolving Property Editor when the Object Type is Menu.

    See "Menu Property Editor " for a description of the editor.

    If no menus exist in the current project, the Menu Objects list will be blank and only the Add New Menu and Edit buttons will be active.

    If any menus exist in the current project, they will be listed in the Menu Objects list. One of the menus will be selected in the list and the menu's properties will be displayed for editing.

  2. Click Add New Menu.

    A menu will be created with a default Object Name ("menu," "menu2," and so on, depending on how many menus there are in the current module), and with two items in the Items list ("Item1" and "Item2"). The menu will be added to the end of the Menu Objects list, with the name of the current module preceding the menu name. The menu will have default values for Object Name, Tearoff, Items, Item Label Type, Label, and Item State.

    If you know you are going to need a number of menus, you could create them all at the same time by clicking Add New Menu the appropriate number of times. You can also create menus that will be used as submenus, to be attached to menu items, at this time.

  3. Edit the menu, as described in "To Edit a Menu " .

    You can edit the menu immediately after creating it or you can edit it later.

After you have created and edited a menu you will want to attach it to an interface object and make the menu functional by creating connections between menu items and specific actions. See "To Attach an Existing Menu to an Object " and "Connecting Menu Items to Actions" for instructions. See "To Attach an Existing Submenu to a Menu Item " if you want to attach a submenu to a menu item.

To Edit a Menu

After creating a menu you will need to edit the menu: add menu items, give the menu items meaningful names, add submenus, and so on.

  1. Display the Menu Property Editor by choosing Menus from the Editors menu in the App Builder primary window.

    Or, display the Revolving Property Editor and choose Menu as the Object Type.

    See "Menu Property Editor " for a description of the editor.

  2. Change Object Name, if necessary.

    The automatically-generated Object names, which are unique within modules, do not usually need to be changed.

  3. Click Enabled to enable the Tearoff function, if necessary.

    This will make the menu "postable," meaning that if you click on the Tearoff indicator (a dotted line) the menu will not be dismissed as soon as you select a menu item. The menu will remain posted until you dismiss it.

  4. Add menu items to the Items list, if necessary.

    Click Add Item to add an item after the selected item; choose from the Edit menu button to perform other edit functions.

  5. Change Item Label Type for menu items in the Items list, if necessary.

    Choices are String (text), Graphic, or Separator. Label becomes Graphic Filename if Graphic is chosen; Line Style becomes active if Separator is chosen.

  6. Type a different Label or Graphic Filename for the selected item, if necessary.


    Note -

    The easiest way to edit labels for menu items is to select the first one in the Items list, thus selecting it in the Label field. Type a new name and click Return. The new name will be displayed in the Items list and the next item in the list will be selected. Continue down the list with this select, type, Return process until all labels are completed.


    If Graphic Item Label Type was chosen, the Graphic Filename must be an xpm or xbm graphic file.

  7. Type an Item Mnemonic, if necessary.

    Type one of the letters in the item label. That letter will be underlined in the menu item label. If the menu is posted, pressing that key will cause the action connected with the menu item to be performed.


    Note -

    The same mnemonic letter, regardless of case, cannot be used more than once in a menu.


  8. Type an Accelerator, if necessary.

    An accelerator is comprised of a prefix (Ctrl, Alt, Meta, or Shift), <Key>, and a letter (uppercase or lowercase). See "Menu Property Editor " for more information.

  9. Choose a Line Style, if Item Label Type is Separator.

    See "Menu Property Editor " for the list of choices.

  10. Attach an Item Submenu, if appropriate.

    See "To Attach an Existing Submenu to a Menu Item " for instructions.

  11. Change Item State, if necessary.

    By default the item state is Active. If you want the menu item to be inactive when the application is started, click the Active check box to deselect it.

  12. Select Background and Foreground Colors, if necessary.

    Type in a color or choose Color Chooser from the menu and select a color from the Color Chooser. See "To Select Colors from the Color Chooser " for details.

  13. Click Connections to add programmatic connections to menu items, as necessary.

    See "Connecting Menu Items to Actions" for instructions.

  14. Click Apply or OK to apply the changes.

    If you click Apply the property editor will remain displayed.

To Attach an Existing Menu to an Object

The following instructions assume you have created one or more menus as described in "To Create a Menu" and that you are ready to attach a menu to an object in the interface. Menus can be attached to menu buttons, menubar items, lists, and any of the four types of panes. A menu is automatically attached to an option menu, so there is no need to attach a menu to it.

  1. Display the Revolving Property Editor with the object to which you wish to attach a menu selected in the editor.

    Double-click the object in the interface or the Module Browser or choose the appropriate Object Type in the Revolving Property Editor and select the desired object in the Objects list.

  2. Select a menu to attach to the selected object.

    Click mouse button 2 or press mouse button 1 or 3 on the Popup Menu or Pulldown Menu menu button. Choose the appropriate menu from the Menus submenu.

    Graphic

    The name of the selected menu will be displayed in the text field of the Popup Menu or Pulldown Menu.

  3. Click OK or Apply.

    The menu will be attached to the selected object. See "Making Connections Between Objects" for instructions for making the menu functional.


    Note -

    If you attach a menu to one of the pane objects or to a list, the menu will be a pop-up menu, displayed in test mode or in the compiled application by pressing mouse button 3 with the cursor on the pane or the list.


To Create and Attach a Menu

One method of creating and attaching a menu to an object is described in "To Create a Menu" and "To Attach an Existing Menu to an Object ". With the method described here you create and attach the menu at one time. Use whichever method is most convenient.

  1. Display the Revolving Property Editor with the object to which you wish to attach a menu selected in the editor.

    Double-click the object in the interface or the Module Browser or choose the appropriate Object Type in the Revolving Property Editor and select the desired object in the Objects list.

  2. Choose Create New Menu from the Pulldown Menu or Popup Menu button available for some objects.

    Pulldown menus are available for menu buttons and menu bars. Popup menus are available for all pane objects and for lists. An Item SubMenu is available for menus themselves.

    The Menu Property Editor will be displayed, with a newly-created menu selected in the Menu Objects list. The menu will have default values for Object Name, Tearoff, Items, Item Label Type, Label, and Item State.

    The Object Name will be of the form "object_type_menu," "object_type_menu2," and so on., depending on what type of object was selected in the property editor when Create New Menu was chosen and how many menus have been created for the current module. The menu will be added to the end of the Menu Objects list, with the name of the current module preceding the menu name.

  3. Edit the menu and click OK to apply the changes and dismiss the Menu Property Editor.

    See "To Edit a Menu " for instructions. You can edit the menu later if you like.

  4. Click Apply or OK in the Revolving Property Editor to attach the menu to the selected object.

    See "Making Connections Between Objects" for instructions for making the menu functional.

To Attach an Existing Submenu to a Menu Item

The following instructions assume you have created two or more menus as described in "To Create a Menu" and that you are ready to attach one of them as a submenu for a menu item.

  1. Display the Menu Property Editor or the Revolving Property Editor with Menu chosen as the Object Type.

  2. In the Menu Objects or Objects list select the menu that contains the menu item to which you want to attach a submenu.

  3. In the Items list select the menu item to which you want to attach a submenu.

  4. Select a menu to attach to the selected menu item.

    Click mouse button 2 or press mouse button 1 or 3 on the Item SubMenu menu button. Choose the appropriate menu from the Menus submenu.

    Graphic

    The name of the selected menu will be displayed in the text field of the Item SubMenu.

  5. Click OK or Apply.

    The submenu will be attached to the selected menu item. See "Making Connections Between Objects" for instructions for making the submenu functional.

To Create and Attach a Submenu

The following instructions assume you have created one or more menus and that you want to create and attach a submenu to one of the items in one of the menus. With this method you create the submenu and attach it as part of a single procedure. Another method for accomplishing this task is to create the menu as described in "To Create a Menu" and to attach it to a menu item as described in "To Attach an Existing Submenu to a Menu Item " . Use whichever method is most convenient.


Note -

When you create and attach a submenu you will be using two editors--one to create the menu and the other to attach the submenu to the menu item. If you start this procedure in the Menu Property Editor, you will be attaching the submenu in the Menu Property Editor but creating it in the Revolving Property Editor. If you start the procedure in the Revolving Property Editor, you will be attaching the menu there but creating it in the Menu Property Editor. The example below assumes you are starting the procedure in the Menu Property Editor.


  1. Display the Menu Property Editor by choosing Menus from the Editors menu of the App Builder primary window.

  2. In the Objects list select the menu that contains the menu item to which you want to attach a submenu.

  3. In the Items list select the menu item to which you want to attach a submenu.

  4. Choose Create New Menu from the Item SubMenu menu.

    The Revolving Property Editor will be displayed, with the new menu selected in the Objects list.

  5. Edit the menu and click OK to apply the editing changes you made and to dismiss the Revolving Property Editor

    See "To Edit a Menu " for instructions. You can edit the menu later if you like.

  6. Click Apply in the Menu Property Editor to attach the submenu to the menu item selected in Step 2. See "Connecting Menu Items to Actions" for instructions for making the submenu functional.

To Create and Attach a Help Menu

A help menu at the right end of the menu bar in the application primary main window is a common feature of applications. Do the following to create a help menu and attach it to the Help item of a menu bar. These instructions assume you have included a menu bar in the primary main window and that Help is one of the menu bar items.

  1. Display the Revolving Property Editor with Menubar selected in the editor.

    Double-click the appropriate menu bar in the interface or the Module Browser or choose Menubar from the Object Type menu in the Revolving Property Editor and select the desired menu bar in the Objects list. This will normally be the menu bar in the primary main window.

  2. Select Help in the Items list.

    This is the Help item on the menu bar.

  3. Click mouse button 2 or press mouse button 1 or 3 on the Pulldown Menu menu button. Choose Create New Menu from the Menus submenu.

    The name of the new menu will be displayed in the text field of the Pulldown Menu and the Menu Property Editor will be displayed with the new menu loaded.

  4. Edit the menu.

    1. If you want a Help menu that looks like the App Builder Help menu, for instance, add four items to the two default items in the Items list. Select each item in turn and type appropriate labels (Overview, Tasks, Reference, On Item, Using Help, and About [application_name], for instance).

    2. Add item mnemonics and accelerators, if appropriate.

      See "Menu Property Editor " for details.

    3. Make other changes to the menu, if appropriate.

  5. Click OK or Apply in the Menu Property Editor.

    The menu is complete. The Menu Property Editor will be dismissed if you click OK.

  6. Click OK or Apply in the Revolving Property Editor.

    The Help menu has been attached to the Help item in the menu bar. The Revolving Property Editor will be dismissed if you click OK.