# Adding a Menu Bar and Menus

You add and modify menus using the menu editor. Menu bars can be added only to frames. If you opened a different type of container, you can change its type to a frame by selecting the container name in the GUI builder's container list and choosing GUI -> Set Window Type. Click on the frame button and click OK.

This section covers:

- Opening the Menu Editor
- Creating Menus
- Changing the Font Type
- Adding a Separator Bar in a Menu
- Creating a Tear-Off Menu

To open the Menu Editor:

1. Select the frame in the layout window by clicking in the area between the layout grid and the window frame.
2. Open the attribute editor by clicking on its button in the main toolbar.
3. Click on the Edit menubar button.

## Creating Menus

The menu list that you create in the menu editor is hierarchical:

- Items that begin in the first column are menus on the menu bar.
- Items that begin in the second column are items in the menu that precedes it hierarchically.
- Items that begin in subsequent columns are pull-right items of the menu item that precedes them hierarchically.
- Separators are added at the same hierarchical level as the menu items they separate.

    This Menu Editor list:		  Produces this menu:

To create a menu:

1. In the menu editor, click in the Name box and enter a unique ID for the menu (for example, `fileMenu`).
2. Click in the Text box and enter a name for the menu item (for example, `File`, `View`, and so on).

   Click on button to the right of the font box to specify the font family, style, and size.

3. Click Insert to insert the next menu.

   Add more menus by repeating steps 1 and 2. A list of the menus appear in order in the display area of the menu editor. Click Apply to add the menu bar (and any subsequent menus or menu items) to the GUI.

To create a menu item for a menu:

1. Select a menu name in the display area of the menu editor.
2. Click Insert to insert a menu item.
3. Click in the Name box and enter a unique ID for the menu item.
4. Click in the Text box and enter a name for the menu item.
5. Click the right-pointing arrow to indent the item.

   Add more menu items by repeating steps 2 through 5. A list of the menu items appear, indented, under the name of the menu that contains them. Click Apply to add the menu items.

Repeat the procedure to add items to each menu in the menu bar.

Use the arrow keys to reorganize the placement of the menus and menu items.

To add a Help menu:

1. Click on Add Help Menu to automatically add a Help menu to the far right end of the menu bar. You add items to the Help menu just as you did for the other menus.
2. After you add the Help menu to the list, type `Help` in the Text box for the menu label.

The Help menu must be the last menu in the list. If you attempt to add additional menus, an error is generated when you apply the changes.

To change the font type:

1. Select a menu name in the display area of the menu editor.
2. Click on the button next to the font box.
3. Choose the font family, style, and point size and click OK.

To add a separator bar in a menu:

1. Select a menu item name in the display area of the menu editor.
2. Click on the Separator button and click OK. In preview mode, a separator bar appears below the selected menu item.

To create a tear off menu:

1. Select a menu name in the display area of the menu editor.
2. Click on the Tearoff Menu button and click OK. In preview mode, the selected menu displays a broken line below the menu name.

See also:

  Adding Operations to Menus
  Laying Out the Interface
  What Is a Component Operation?
  Adding Custom Components and Windows