Create a new sheet menu

Where you are

   Modify the frame menu

>   Create a new sheet menu

   Add menu scripts to trigger user events

   Attach the new menu and run the application

Now you create a new menu that displays whenever the user opens an MDI sheet to look at customer or product information. The menu you create is a descendant of the m_pbtutor_sheet menu that was generated by the Template Application wizard.

The m_pbtutor_sheet menu inherits in turn from m_pbtutor_frame, but has some additional menu items enabled. In the menu you create, you add menu items that are not present in the ancestor menus.

In this exercise you:

Inherit and save a new menu

By inheriting from the application sheet menu, you retain the sheet menu characteristics without modifying the ancestor menu. It is good practice to save the new menu immediately, then save it again after you modify it.

  1. Click the Inherit button () in the PowerBar.

    The Inherit From Object dialog box displays.

  2. Make sure Menus is selected in the Objects of Type drop-down list box.

    Select m_pbtutor_sheet in the Object list box and click OK.

    PowerBuilder displays an untitled menu that has all the characteristics of m_pbtutor_sheet.

    On the inherited sheet menu, the Window menu items are enabled to allow for tiling and cascading windows, just as they are for the m_pbtutor_sheet menu. These items are disabled on the m_pbtutor_frame menu.

    Changes made to the MDI frame menu

    If you click the File menu in the WYSIWYG view, you see that the first item is now Report. The Open item is dithered to indicate that it is not visible and is grayed to indicate that it is disabled. These characteristics were propagated through the inheritance chain from m_pbtutor_frame.

  3. Select File>Save from the menu bar.

    The Save Menu dialog box displays.

  4. Type m_my_sheet as the menu name in the Menus box.

    Type the following line in the Comments box:

    New sheet menu for w_master_detail_ancestor and its descendants.
  5. Click OK.

    This names the menu. The prefix m_ is standard for menus.

    The name you just assigned to the new menu displays in the title bar of the Menu painter workspace and the m_my_sheet menu appears in the system tree.

Add items to the new menu

Next you add items to the Edit menu of the menu you just inherited from m_pbtutor_sheet. You use the WYSIWYG and Properties views.

  1. Click the Edit menu in the WYSIWYG view for the new menu.

    The list of Edit menu items appears just as it would in a runtime application. All items of the Edit menu are visible but disabled (they appear gray -- but not dithered -- in the WYSIWYG view).

  2. Right-click a menu item under the Edit menu in the WYSIWYG view.

    Select Insert Menu Item At End from the pop-up menu.

    The cursor moves into a blank box that appears at the end of the Edit menu list.

  3. Click in the box that appears at the bottom of the menu, and type - (hyphen). Press Enter.

    The hyphen changes into a separator line. In the Properties view, the menu item name changes to m_0. Even the separator lines between menu items must have unique names. Other separator lines in the menu have a unique index number preceded by the prefix m_dash.

  4. Clear the Enabled check box in the Properties view for the new separator line.

  5. Right-click the new separator line in the WYSIWYG view.

  6. Select Insert Menu Item At End from the pop-up menu.

  7. Type &Insert in the box that appears under the new separator and press Enter.

    The menu item name is set automatically to m_insert. If PowerBuilder displays a message that the default name is incorrect, it suggests an alternative name. If this occurs, click OK to accept the suggested name.

    Alternative method of inserting menu item names

    You can type &Insert in the Text box in the Properties view instead of typing it in the box that appears in the WYSIWYG view. In this case, you do not need to press Enter afterwards. First, however, you have to clear the Lock Name check box if the Name box is grayed (otherwise, the menu name does not reset to m_insert).

  8. Type Insert a row in the MicroHelp box in the Properties view.

    The new menu item is visible and enabled by default.

    The text Insert a row displays in the MicroHelp line at the bottom of the application window whenever the user selects the menu item.

  9. Repeat steps 5 and 6 for the following menu items:

    Menu item

    MicroHelp text

    Upd&ate

    Update the database

    &Delete

    Delete the current row


    You add Edit menu items for updating and deleting database records. Even though it is not enabled, the Undo item already uses the letter U as an accelerator key, so you should not use the same accelerator key for the Update menu item. Instead, you use the letter A for this purpose.

Add a new toolbar for the new menu items

Now you add toolbar buttons for the menu items you just defined and then place them in a second toolbar.

  1. Click the new Insert menu item in the WYSIWYG view Edit menu.

  2. Click the Toolbar tab in the Properties view.

    Type Insert in the ToolbarItemText box.

    Type or select Insert! in the ToolbarItemName drop-down list.

    This defines a toolbar button for the Insert menu item that uses the stock picture called Insert!. When the Show Text option in the runtime application is enabled for toolbars, the text Insert appears on the button.

  3. Type or click to 1 in the ToolbarItemSpace spin control.

    Type or click to 1 in the ToolbarItemOrder spin control.

    Type or click to 2 in the ToolbarItemBarIndex spin control.

    When you start a new toolbar for the added menu items, the Insert button will be the first item in this toolbar.

  4. Click the new Update menu item in the WYSIWYG view Edit menu.

    Make sure it is also displayed on the title bar in the Properties view.

  5. Click the Toolbar tab if the Toolbar page is not already open.

    Type Update in the ToolbarItemText box.

    Type or select Update! in the ToolbarItemName drop-down list box.

    This defines a toolbar button for the Update menu item that uses the stock picture called Update!. The button text is Update.

  6. Type or click to 2 in the ToolbarItemOrder spin control.

    Type or click to 2 in the ToolbarItemBarIndex spin control.

    This will add the Update button after the Insert button in the new toolbar.

  7. Click the new Delete menu item in the WYSIWYG view Edit menu.

    Make sure it is also displayed on the title bar in the Properties view.

  8. Click the Toolbar tab if the Toolbar page is not already open.

    Type Delete in the ToolbarItemText box.

    Type or select DeleteRow! in the ToolbarItemName drop-down list box.

    This defines a toolbar button for the Delete menu item that uses the stock picture called DeleteRow!. The button text is Delete.

  9. Type or click to 3 in the ToolbarItemOrder spin control.

    Type or click to 2 in the ToolbarItemBarIndex spin control.

    You add the Delete button after the Update button in the new toolbar.

  10. Select File>Save from the PowerBuilder menu bar.