WwPopupMenu Function

Creates a popup menu.

Usage

popup = WwPopupMenu(parent, items)

Input Parameters

parent — The widget ID of the parent widget.

items — An unnamed structure specifying the menu bar items. For more details, see "Creating and Handling Menus" in the PV‑WAVE Application Developer’s Guide.

Returned Value

popup — The widget ID of the popup menu widget.

Keywords

Menus — Returns an array of menu pane widget IDs in the order in which the menus were created. A menu pane is a special menu widget that serves as a container for a menu item. Menu pane widget IDs can be used in the WwMenuItem function to add, modify, or delete menu items.

Name — A string specifying the name of the PopupMenu widget. The Name specified is part of the resource specification. (Default: menu.)

Color/Font Keywords

For Unix:

Background — Specifies the background color name.

Font — Specifies the name of the font used for text.

Foreground — Specifies the foreground color name.

For Windows:

MSFont — Adds support for Windows fonts.

Get/Set Value

getvalue — The button label or icon pixmap ID for the selected menu button. Or, if the button is a toggle, returns whether it is selected or unselected (selected = 1, unselected = 0).

setvalue — The button label or icon pixmap ID for the selected menu button. Or, if the button is a toggle, selects or unselects the toggle button (select = 1, unselect = 0).

Callback Parameters

Any popup menu callback procedure must have the following two parameters:

wid — Widget ID of the selected menu item.

index — Index of the selected menu item (1 – n).

Discussion

A popup menu is a menu that appears when the user presses a mouse button (usually the right button) when the pointer is in the popup menu’s parent widget. Thus, the popup menu is not tied to any menu button or menu bar.

Note:

Avoid creating popup menus that have a multi-line text widget as a parent. The system editing menu may appear over the popup menu that you have defined.

Example

This example creates a drawing widget that serves as the parent for a popup menu. The popup menu is activated when the right mouse button is pressed while the pointer is over the drawing widget. The callback procedure is executed when a menu button is selected.

Enter the callback procedures into a file, and compile the procedures with the .RUN command. Then, enter the widget commands at the WAVE> prompt (or enter them in a command file and run them with the @ command). To dismiss the button box, select the appropriate function (such as Close) from the window manager menu.

Callback Procedures

PRO DrawCB, wid, data
   COMMON draw, img
   PRINT, 'Draw'
   TV, img
END
PRO MenuCB, wid, index
   PRINT, 'Menu Item', index, 'selected.'
   VALUE = WwGetValue(wid)
   PRINT, value
END

Widget Commands

top = WwInit('ww_ex32', 'Examples', layout)
COMMON draw, img
LOADCT, 5, /SILENT
img = BYTARR(512,512)
OPENR,1, !Data_Dir + 'head.img'
READU,1,img
CLOSE, 1
draw = WwDrawing(layout, 1,'DrawCB', [256,256], [512,512])
status = WwSetValue(top, /Display)
menus = {,callback:'MenuCB', $
menubutton:'Fonts', $
menu:{,callback:'MenuCB', $
menubutton:'Adobe', $ 
menu:{,callback:'MenuCB', $ 
toggle:'Normal', $ 
   toggle:'Bold', $
   toggle:'Italic'}, $ 
   button:'Helvetica', $ 
   button:'Courier'}, $ 
menubutton:'Size', $ 
menu:{,callback:'MenuCB', $ 
   button:'8', $ 
   button:'10', $ 
   button:'12'}}
menu = WwPopupMenu(draw, menus)
status = WwSetValue(top, /Display)
WwLoop

See Also

WwMenuItem, WwMenuBar, WwOptionMenu

For detailed information on GUI development, refer to the PV‑WAVE Application Developer’s Guide.

For more information about how to write an application program based on PV‑WAVE Widgets, refer to Using Wave Widgets in the PV‑WAVE Application Developer’s Guide.

For additional information on the color and font keywords, see "Setting Colors and Fonts" in the PV‑WAVE Application Developer’s Guide.

For information on Get and Set values, see "Setting and Getting Widget Values" in the PV‑WAVE Application Developer’s Guide.