Schultz’s PowerBuilder Notes

Pop Up Menus

Launching a Pop Up Menu

menuname.PopMenu ( xlocation, ylocation )


m_pop_lists lm_pop

lm_pop = CREATE m_pop_lists
lm_pop.PopMenu(xpos, ypos)

The xpos and ypos are relative to the object, but when the menu pops, the x and y arguments are relative to the window. If the menu is poping up on a user object, you will need to refer to the parent window:

m_pop_lists lm_pop
w_sheet lw_sheet

li_rc = of_GetParentWindow(lw_sheet)

lm_pop = CREATE m_pop_lists
lm_pop.PopMenu(lw_sheet.PointerX(), lw_sheet.PointerY())

Sample menu clicked event


of_notify(string a_item)

Message.StringParm = a_item

Routing to a window event

window lw_active_sheet
w_frame lw_frame

lw_frame = gnv_app.of_GetFrame()
lw_active_sheet = lw_frame.GetActiveSheet()

Parent Window’s ue_menu_button event

ls_message = Message.StringParm
choose case ls_message
   case "m_tradeoff"
      wf_LaunchTrade(ll_row, lnv_dictionary, TRUE)
   case "m_tradeon"
      wf_LaunchTrade(ll_row, lnv_dictionary, FALSE)
   case else
      if IsNull(ls_message) then
         ls_message = “[null]”
      end if
      MessageBox(“Error – “, “Unknown menu selection :”)
End Choose

Routing to the parent datawindow event

First you need to add a menu function of_setParent(datawindow adw_parent) to register the parent window idw_parent.

//    Function:  of_SetParent
//    Access:  public
//    Arguments:
//    adw_parent   parent object of the menu
//    Returns:  integer
//     1 = success
//    -1 = failure, parent reference is not valid
//    Description:  Sets the parent object of this menu
//    Revision History

integer    li_rc = 1

if IsValid (adw_parent) then
   idw_parent = adw_parent
   li_rc = -1
end if

return li_rc

After creating the menu, call this function

lm_dw = CREATE m_vc // Create rmb menu
ll_rc = lm_dw.of_setparent(this)
m_dw.m_table.PopMenu(li_x + 5, li_y + 5)

In the menu item’s clicked event, trigger the user event on the parent datawindow



April 9, 2008 - Posted by | Menus | , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: