2.12.7 Creating a Popup Menu

Popup menus are displayed when the user selects a component and clicks the right mouse button. They are typically used to create shortcuts to options commonly associated with a component.

To create a popup menu open the Menus group in the Groups tab of the Repository tab. Drag a popup menu to the component you want to associate it with. Alternatively, right-click a component to bring up its popup menu and select the Popup Menu option. An edit box where you can enter the captions of the menu items is displayed on the top of the Design view.


Enter the captions of your menu items in the edit box. To add a item, press the Enter key.

At run-time when the user right-clicks the field the popup menu is displayed:

To edit the popup menu after you have created it, right-click the component it is associated with and choose the Edit Popup Menu option. Alternatively, select the popup menu in the Outline tab.

Note that when you are creating a popup menu for a field, you can add automatically enabled options for Cut, Copy and Paste. These options allow the end user to cut, copy and paste the value of the field.

If you want to use any of these automatic options, use the AutoActions property of the popup menu. (In the current version only these three autoactions have been implemented and they only apply to fields).

The popup menu and the component are associated using the PopupMenu property of the component. You can use this property to assign a popup menu to another component:

Note that you can use the same popup menu with more than one component. For example in a explorer-type interface (a tree view on the left and a list view on the right), you would typically use just one popup menu:




Then for every single menu item in the popup menu, you would write the code to perform an action depending on the type of item selected. In this example the tree view key columns are sourced from the #DEPTMENT and #SECTION fields, and the list view key column is sourced from the #EMPNO field:


if '#empno *ne *blanks'

   invoke #EmpForm.activateForm

   set #EmpForm emp_value(#empno) emp_dept(#deptment) emp_sect(#section)


if '#section *ne *blanks'

   invoke #SecForm.activateform

   set #SecForm dept_value(#deptment) sect_value(#section) top(#std_num)


if '#deptment *ne *blanks'

   invoke #DeptForm.activateform

   set #DeptForm dept_value(#deptment)