popupmenu -- open a popup menu
Selected$ = POPUPMENU x,y, MenuItems$, View$
This function pops up a menu at the position (x,y) as upper left corner on View$. The menu contains several menu items which are given as MenuItems$. The items are separated by a pipe "|". If a menu item is a double minus, it will be used as a separator.
Your program will wait until an item is selected from the menu or the user clicks somewhere else. The command will then return either the selected item name or an empty string "" when nothing was selected.
Note, you cannot add submenus, have a radio mode or select items which is possible for menus in a menubar.
Similar to the menu, the Selected$ will contain the translation of the selected item when localization is used. Use translate$ where necessary, as explained for the menu command.
Remember to give the user a hint so he can expect a popup menu. E.g. add a small down-arrow to a button image, if this button opens a popup menu.
window open 100,100 to 300,300, "Example", "Example"
button 10,10 to 100,30, "MyButton", "Popup", "Example"
m$ = message$
if(instr(m$, "Quit")) quitting = true
if(instr(m$, "MyButton")) then
selected$ = popupmenu 10,31, "About...|--|Quit", "Example"
if(selected$ = "About...") alert "Popupmenu example.", "Ok", "Info"
if(selected$ = "Quit") quitting = true
window close "Example"
The example opens a window with a button. Whenever the button is clicked on, a popup menu appears. The selection of the popup menu is then processed immediately.