Add menu scripts to trigger user events

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 add scripts to trigger user events from the sheet window menu bar. You added these user events in Modifying the Ancestor Window. The Menu painter should still be open for the m_my_sheet menu. If it is not, you can open it using the Open button in the PowerBar.

  1. Select m_edit.m_insert in the first list box in the Script view


    Double-click the Insert menu item in the WYSIWYG view.

    The full name of the Insert menu item displays in the first list box of the Script view. It includes the m_edit prefix to indicate that it is in the Edit menu.

  2. Select Clicked in the second drop-down box if it is not already selected.

    Type these lines for the Clicked event:

    w_master_detail_ancestor lw_activesheet
    lw_activesheet = w_pbtutor_frame.GetActiveSheet()
    lw_activesheet.EVENT ue_insert()

    The first two lines determine which sheet in the MDI frame is currently active. The third line triggers the user event ue_insert for the active sheet.

  3. Repeat steps 1 and 2 for the following menu items and scripts:

    Menu name

    Script for Clicked event


    w_master_detail_ancestor lw_activesheet
    lw_activesheet.EVENT ue_update()


    w_master_detail_ancestor lw_activesheet
    lw_activesheet = w_pbtutor_frame.GetActiveSheet()
    lw_activesheet.EVENT ue_delete()

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

    PowerBuilder compiles and saves the menu scripts.

  5. Click the Close button in PainterBar1


    Select File>Close from the PowerBuilder menu bar.