Inserting menu items in a descendent menu

Modifying the ShiftToRight property

When defining a descendent menu, you might want to insert menu items in the middle of the menu bar or in the middle of a drop-down or cascading menu. To do this, you set the ShiftToRight property in a menu item’s Properties view on the General property page.

If the ancestor menu has no menu items with ShiftToRight set, you can add a new menu item to the end of the descendent menu. To add new menu items elsewhere in the menu, set the ShiftToRight property for the descendent menu items that will follow the new menu item.

The ShiftToRight property is used for menu items on the menu bar (where items need to shift right if a new item is inserted) and for menu items in a drop-down or cascading menu (where items might need to shift down if a new item is inserted). The property name is ShiftToRight, but it means shift down in drop-down or cascading menus.

Where you set the ShiftToRight property

You set the ShiftToRight property in an ancestor menu only if you know that you will always want a group of menu items to shift right (or down) when you inherit from the menu and add a new menu item. For example, if you have File, Edit, Window, and Help menus on the menu bar, set the ShiftToRight property for the Window and Help menu items if you are going to inherit from this menu, because Window and Help are usually the last items on a menu bar.

Where you can insert menu items in a descendent menu

In a descendent menu, a group of menu items can be one of four types. Each type has an insertion rule.

Table 14-7: Insertion rules for groups of menu items

Type of group

Insertion rule

Inherited menu items without ShiftToRight set

You cannot insert a new menu item before any of these menu items

Inherited menu items with ShiftToRight set in ancestor

You can insert before the first menu item in the group but not before the others

New items without ShiftToRight set

You can insert a new menu item before any of these menu items

New items with ShiftToRight set

You can insert a new menu item before any of these menu items

The “Example with no ShiftToRight in ancestor” and the “Example with ShiftToRight in ancestor” demonstrate some of these rules.

How to insert menu items in a descendent menu

If you can insert a menu item in a descendent menu, the Insert Menu Item option on the Insert menu and the pop-up menu is enabled. The Insert Menu Item is enabled if ShiftToRight is set in the selected item that will follow the item you are inserting and all menu items following it.

To insert a menu item in a descendant, you use the same method you use to insert an item in a new menu, whether the menu item is on the menu bar or on a drop-down or cascading menu. For information about inserting menu items, see “Working with menu items”.

The following examples illustrate where you can insert menu items in a descendent menu and demonstrate the rules that govern where you can insert them.

Example with no ShiftToRight in ancestor

Suppose you have a menu with File, Edit, Window, and Help items on the menu bar. The menu is inherited from an ancestor frame menu with no items set as ShiftToRight in the ancestor.

The left pane of the sample screen shows the menu bar with the options File, Edit, Window, and Help displayed horizontally from left to right. The right pane displays the same menu options unexpanded and indented under the new menu named untitled 0.

Here is how you might add some new menu items. Since ShiftToRight is not set anywhere at first, you can add a menu item only to the end.

  1. Select any item in the menu bar and select Insert>Menu Item At End.

  2. Name the new menu item New1 and press Enter.

    The New1 menu item is added to the right of the Help menu.

    The sample shows the menu bar with the options File, Edit, Window, Help, and New 1 displayed horizontally, left to right.

    Now add a new Menu item before the New1 menu item. You can do this without setting ShiftToRight on New1, because New1 is a new menu item in the inherited menu.

  3. Select Insert Menu Item from the pop-up menu for New1.

  4. Name the new menu item New2 and press Enter.

    The sample shows the menu bar with the options File, Edit, Window, Help, New 2, and New 1 displayed horizontally, left to right.

    Now add a new Menu item before the Help menu item. You cannot do this unless you set ShiftToRight on the Help menu item, the New2 Menu item, and the New1 menu item, because Help is an inherited menu item without ShiftToRight set in the ancestor menu. For Help to shift right, New2 and New1 must also be able to shift right.

  5. Select the Help menu item and in the Properties view, select the ShiftToRight property, and then do the same for New1 and New2.

    Now you can add a new menu item before the Help menu item.

  6. Select the Help menu item, then select Insert New Item from the pop-up menu, name the new item New3, and then press Enter.

    The sample shows the menu bar with the options File, Edit, Window, New 3, Help, New 2, and New 1 displayed horizontally, left to right.

    If you want to add a new Menu item before the New3 menu item, you can do it without setting ShiftToRight on New3, because New3 is a new menu item and ShiftToRight is set in all items that follow.

    However, if you want to add a new menu item before the Window menu item, you cannot do this by working only in the descendent menu because the Window menu item is an ancestor menu item and ShiftToRight is not set in the ancestor. To be able to do this, you must set Window as ShiftToRight in the ancestor.

Example with ShiftToRight in ancestor

In this example, the inherited menu has the same four menu bar items, but ShiftToRight has been set in the Window and Help menu items in the ancestor menu. Suppose you want to insert a new menu item before the Help menu item and the Window menu item.

  1. Select the Help menu item and display the pop-up menu.

    The Insert Menu Item option is disabled because the Help item is not the first item in a group of ancestor menu items (Window and Help) with ShiftToRight set in the ancestor.

  2. Select the Window menu item and display the pop-up menu.

    The Insert Menu Item option is enabled because the Window item is the first item in a group of ancestor menu items with ShiftToRight set in the ancestor.

  3. Select Insert Menu Item At End from the pop-up menu to insert a new menu item after Help, name it New1, and press Enter.

    The New1 item’s ShiftToRight property is set automatically.

    Now the Window, Help, and New1 items are set ShiftToRight. You can insert a new item before Window and New1, but not before Help. This is because the Window and Help menu items are a group for which ShiftToRight is set in the ancestor.

    You cannot insert a new item before the Edit menu item because Edit is in a group (File and Edit) that are inherited items with no ShiftToRight set in the ancestor.

  4. Select the Edit menu item, select ShiftToRight in the Properties view, and then add a new menu item.

    The sample shows the menu bar with the options File, New 2, Edit, Window, Help, and New 1 displayed horizontally, left to right.

    You could also have set the ShiftToRight property in the ancestor menu, but it is easier to work just in the descendant.