The popup statement makes a pop-up menu appear anywhere on the screen.
Parameters
This statement has five parameters:menu – specifies the contents of the menu. In its simplest form, this can simply be a carriage return separated array. Each line of the array specifies one menu item. (If a menu item is (-
, it is displayed as a separator line.) If you want to create a more complex menu (colors, styles, fonts, submenus, etc.) you can create the menu with the menu( and menuitem( functions (see Custom Menus).
v – is the vertical position of the pop-up menu. The position is measured in points from the top of the form.
h – is the horizontal position of the pop-up menu. The position is measured in points from the left edge of the form.
initial – is the initial value of the menu. This value should be one of the items in the menu. The menu will pop up with the arrow over this item. For example, suppose the pop-up menu contains the items Red, Blue and Green and the current value is Blue. “Blue” should be the initial value.
result – is a variable where the user’s choice from the pop-up menu will be stored. If the user releases the mouse without making a choice, the result will be left untouched. Note: If the menu was constructed with identifiers you can also use the info(“menuidentifier”) function to determine the chosen menu item.
Description
The popup statement makes a pop-up menu appear anywhere on the screen, without an associated form object. The popup statement is usually used with a transparent button with the click/release option turned off. In other words, as soon as someone clicks on the button, the procedure triggers and the pop-up menu pops up. (Note: It is usually easier to use a PopUp Menu Button form object instead of using the popup statement. However, you must use the popup statement (or popupbynumber) if the menu items cannot be calculated with a formula, but require one or more procedure statements to compute.)
This example allows the user to choose a color.
local btop,bleft,bheight,bwidth,NewColor
getlocalbutton btop,bleft,bheight,bwidth
NewColor="Green"
popup "Red"+cr()+"Green"+cr()+"Blue"+cr()+"(-"+cr()+"Black",
btop,bleft,"Blue",NewColor
This example allows the user to choose a color, and displays the menu items in color.
local btop,bleft,bheight,bwidth,NewColor
getlocalbutton btop,bleft,bheight,bwidth
NewColor="Green"
popup menu("Popup")+
menuitem("Red","Color","FF0000")+
menuitem("Green","Color","00FF00")+
menuitem("Blue","Color","0000FF")+
menuseparator()+
menuitem("Black"),
btop,bleft,"Blue",NewColor
Note: If both the v and h parameters are -1, the menu will pop up at the current mouse location.
local NewColor
NewColor="Green"
popup "Red"+cr()+"Green"+cr()+"Blue"+cr()+"(-"+cr()+"Black",
-1,-1,"Blue",NewColor
See Also
History
Version | Status | Notes |
10.0 | Updated | Carried over from Panorama 6.0, however, this version does not allow menus to be displayed from resources. Also, if both v and h parameters are -1, the menu will pop up at the current mouse location. |