Add menu scripts to trigger user events

Note

Now you add scripts to trigger user events from the sheet window menu bar. You added these user events in Lesson 5, “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

    or

    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

    m_edit.m_update

    w_master_detail_ancestor lw_activesheetlw_activesheet=w_pbtutor_frame.GetActiveSheet()lw_activesheet.EVENT ue_update()

    m_edit.m_delete

    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

    or

    Select File>Close from the PowerBuilder menu bar.