Previous User Interface Programming: Using the IDL GUIBuilder Next

Using the Menu Editor

You can add menus to top-level bases or to buttons that have the Type attribute set to Menu. To define menus for your interface, use the Menu Editor, which is shown in the following figure with defined menus. This dialog allows you to define menus, menu items, submenu titles, and submenus, and all their associated event procedures.

For instructions on how to define the menus shown in the following figure, see Defining Menus for the Top-level Base.

Figure 3-9: Menu Editor Dialog

Figure 3-9: Menu Editor Dialog

Adding Menus to Top-Level Bases

To define basic menus, menu items, submenu titles, submenus, and their associated event procedures to top-level bases, follow these general steps:

  1. Open the Menu Editor by doing one of the following:
    • Select the top-level base and select Edit Menu from the IDLDE menu.
    •  

    • Right-click on the top-level base, then choose Edit Menu.

     

  2. To define a top-level menu in the Menu Editor, enter a Menu Caption, and click Insert. When you are defining menus for a top-level base, the top-level menus are aligned along the left edge of the menu list, and the indentation indicates the nesting in the menu.
  3.  


    Note
    The Menu Caption is the name that appears on the menubar. If you are defining a top-level menu for a base, you do not need to supply a value in the Event Procedure field. On button menus, however, where the button's Label attribute acts as the top-level menu, the first level of menus in the editor serve as menu items, and thus require a value in the Event Procedure field.

     

  4. To define a menu item on a new line in the editor, click the right arrow, enter a Menu Caption and its associated event procedure, then click Insert. The Menu Caption is the name you want to appear on the menu. The Event Procedure is the name of the routine that will be called when the menu item is selected.
  5.  


    Note
    For top-level bases, you must indent a line to make it a menu item and enable the Event Procedure field.

     

  6. To define a submenu title, enter the Menu Caption, and click Insert. It is not necessary to define an Event Procedure for a submenu title.
  7.  

  8. To define submenus to a submenu title, enter the Menu Caption and the Event Procedure, indent the item another level by using the right arrow, and click Insert. Enter the submenus you want at this level of indentation.
  9.  

  10. To define another top-level menu or menu item, enter the information, click the left arrow until the indentation is appropriate, and click Insert.
  11.  

  12. To define a separator, select a blank line, or select the line you want the separator after, then click the separator button (which has a line on it and is above the arrow buttons).
  13.  

  14. To save your defined menus, Click OK in the Menu Editor. When you do so, the menu items will appear on the top-level base. To test the display of the menus, click on them.
  15.  


    Note
    Under Microsoft Windows, including the ampersand character (&) in the Menu Caption causes the window manager to underline the character following the ampersand, which is the keyboard accelerator. This functionality is supported in the Menu Editor. If you are designing an application to run on other platforms, however, avoid the use of the ampersand in the Menu Caption.

     

  16. To move a menu item to a new position: Select the menu item, click the up or down arrow on the right side of the dialog until the menu item is in the desired position, then click OK.
  17.  

  18. To add a menu item in the middle of existing menu items: Select the line you want the new item to follow, then click Insert. This adds a new line, for which you can enter a Menu Caption and Event Procedure.
  19.  

  20. To make a menu item display disabled initially: Click the Enabled checkbox (to uncheck it). All menu items are enabled by default.
  21.  

  22. To enable the ability to place a check or selection box next to the menu item: Click the Checked checkbox. (Checkmarks are placed next to menu items via the SET_BUTTON keyword to WIDGET_CONTROL in the event handling routine.)
  23.  

  24. To delete a menu item: Select the item, then click Delete.
  25.  

  26. To delete a menu: Delete each contained menu item, then delete the top-level menu.

Adding Menus to Buttons

You can also create buttons that contain menus. To add a menu to a button, follow these basic steps:

  1. Click on the Button widget tool on the toolbar, then click on the top-level base area. This creates a button of the default size.
  2.  

  3. Right-click on the button and choose Properties to open the Properties dialog.
  4.  

  5. In the Properties dialog, change the value of the Type attribute to Menu.
  6.  

  7. Right-click on the button, then choose Edit Menu to open the Menu Editor. You can define the menu items and submenus with the Menu Editor, using the general steps described in Using the Menu Editor.
  8.  


    Note
    For buttons, the Label attribute acts as the top-level menu, and the first level of menus in the Menu Editor serve as menu items. Therefore, the first level requires a value in the Event Procedures field (unlike top-level menu items for bases).

     

  9. After you have defined all the necessary menus, click OK. When you do so, the menus are saved, and the button Label attribute is displayed as the top-level menu.

To view menus on buttons, do one of the following:

  IDL Online Help (March 06, 2007)