popupbynumber
MENU
,
V
,
H
,
INITIAL
,
RESULT

The popupbynumber 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 a number from one to the number of items in the menu. The menu will pop up with the arrow over this item. For example, if the initial value is 3 the menu will pop-up over the third item.

result – is a variable where the user’s choice from the pop-up menu will be stored. The result is returned as a number: 1 for the first menu item, 2 for the second menu item, etc. 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 popupbynumber statement makes a pop-up menu appear anywhere on the screen, without an associated form object. The popupbynumber 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 popupbynumber statement (or popup) 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=0
popupbynumber "Red"+cr()+"Green"+cr()+"Blue"+cr()+"(-"+cr()+"Black",
    btop,bleft,3,NewColor

This example allows the user to choose a color.

local btop,bleft,bheight,bwidth,NewColor
getlocalbutton btop,bleft,bheight,bwidth
NewColor=0
popupbynumber menu("Popup")+
     menuitem("Red","Color","FF0000")+
     menuitem("Green","Color","00FF00")+
     menuitem("Blue","Color","0000FF")+
     menuseparator()+
     menuitem("Black"),
     btop,bleft,3,NewColor

Note: If both the v and h parameters are -1, the menu will pop up at the current mouse location.

local NewColor
NewColor=0
popupbynumber "Red"+cr()+"Green"+cr()+"Blue"+cr()+"(-"+cr()+"Black",
    -1,-1,"Blue",NewColor

See Also


History

VersionStatusNotes
10.0UpdatedCarried 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.