Adding, Inserting, and Deleting Menu Items

From RAD Studio
Jump to: navigation, search

Go Up to Building Menus


The following procedures describe how to perform the basic tasks involved in building your menu structure. Each procedure assumes you have the Menu Designer window open, as described in Opening the Menu Designer.

To add menu items at design time

  1. If you have just opened the Menu Designer, the first position on the menu bar is already selected:
    MenuDesignerOpened.jpg
    Begin typing to enter the caption for the menu (the label that will appear in your application).
    While you are entering your caption, notice that the Menu Designer does not reflect your typing, but the Object Inspector does (in the value field for the Caption property).
    If the Menu Designer is displaying an existing menu, select the position where you want to create the menu item.
  2. Press Enter. Your Caption text appears in the Menu Designer, and the next placeholder for a menu item is selected. For example, here is the Menu Designer after you enter the caption "File" and press Return (and the current TMenuItem is the first item in the File menu):
    MenuDesignerStep2.jpg
    Note: For a TMenuItem, the IDE automatically uses the Caption property to derive the Name property if you enter the Caption before entering the Name. In any case, to change the Name property, click the value in the Object Inspector, and enter a new value or edit the existing value.
    If you entered the Caption property first, use the arrow keys to return to the menu item you just entered. You'll see that Delphi has filled in the Name property based on the value you entered for the caption. (See Naming the menu items.)
  3. Continue entering values for the Name and Caption properties for each new item you want to create, or press Esc to return to the menu bar.
    Use the arrow keys to move from the menu bar into the menu, and to then move between items in the list; press Enter to complete an action. To return to the menu bar, press Esc.

To insert a separator bar in a menu

  1. In the Menu Designer, highlight the position above which you want to place the separator bar. For example, if you highlight an item named Copy, the separator bar is placed above the Copy item in the menu.
  2. Right-click the Menu Designer.
  3. Select Insert Separator from the context menu.
  4. Note that a separator bar is basically a menu node whose Caption field on the 'Object Inspector contains only a hyphen.

To insert a new, blank menu item

  1. Place the cursor on a menu item.
  2. Press Insert on the keyboard or right-click and select Ins on the Menu Designer context menu.
    Menu items are inserted to the left of the selected item on the menu bar, and above the selected item in the menu list.

To delete a menu item or command

  1. Place the cursor on the menu item you want to delete.
  2. Press Delete on the keyboard or right-click and select Del on the Menu Designer context menu.

Note: You cannot delete the default placeholder that appears below the item last entered in a menu list, or next to the last item on the menu bar. This placeholder does not appear in your menu at run time.

To automatically create a menu

You can also automatically create a menu by using action lists instead of the Menu Designer, as described in:


See Also