WwOptionMenu Function
Usage
option = WwOptionMenu(parent, label, items)
Input Parameters
parent — The widget ID of the parent widget.
label — A string containing the text of the option menu label. If this parameter is a null string, the Name keyword is used instead.
items — An unnamed structure specifying the option menu items. For more information, see "Creating and Handling Menus" in the PV‑WAVE Application Developer’s Guide.
Returned Value
option — The widget ID of the option menu box.
Input Keywords
Name — A two-element string array. The first element, name(0), contains the name of a pulldown widget; the second element, name(1), contains the name of the option menu.
The Name keyword can be used in place of the label parameter, although label (if other than a null string) will take precedence if both are given.
Position — If the option menu widget is to be placed in a bulletin board layout, use this keyword to specify the x, y coordinates of the option menu widget within the bulletin board.
Output 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.
Color/Font Keywords
Background — Specifies the background color name.
Font — Specifies the name of the font used for the button text.
MSFont — Adds support for Windows fonts.
Foreground — Specifies the foreground color name.
Attachment Keywords
Bottom — If a widget ID is specified (for example, Bottom=wid), then the bottom of the option menu widget is attached to the top of the specified widget. If no widget ID is specified (for example, /Bottom), then the bottom of the option menu widget is attached to the bottom of the parent widget.
Left — If a widget ID is specified (for example, Left=wid), then the left side of the option menu widget is attached to the right side of the specified widget. If no widget ID is specified (for example, /Left), then the left side of the option menu widget is attached to the left side of the parent widget.
Right — If a widget ID is specified (for example, Right=wid), then the right side of the option menu widget is attached to the left side of the specified widget. If no widget ID is specified (for example, /Right), then the right side of the option menu widget is attached to the right side of the parent widget.
Top — If a widget ID is specified (for example, Top=wid), then the top of the option menu widget is attached to the bottom of the specified widget. If no widget ID is specified (for example, /Top), then the top of the option menu widget is attached to the top of the parent widget.
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 option 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
An option menu is a button that, when selected, displays a menu. The current selection is always displayed on the option menu button. When the user makes a selection, the option menu button is updated to reflect the change.
Pullright menus are not allowed in an option menu.
Example 1
This example creates an option menu. The menu information is defined in an unnamed structure called fonts. The callback routine, MenuCB, is called whenever a menu item is selected.
Enter the callback procedure into a file, and compile the procedure with the .RUN command. Then, enter the widget commands at the WAVE> prompt. To dismiss the option menu, select the appropriate function (such as Close) from the window manager menu.
Callback Procedure
PRO MenuCB, wid, index
PRINT, 'Menu Item', index, 'selected.'
value = WwGetValue(wid)
PRINT, value
END
Widget Commands
top = WwInit('ww_ex31', 'Examples', layout)
fonts = {,callback:'MenuCB', $
button:'Adobe', button:'Helvetica', button:'Courier'}
opmenu = WwOptionMenu(layout, 'Fonts:', fonts, Position=[0,150])
status = WwSetValue(top, /Display)
WwLoop
Example 2
A typical resource specification for a menu label used in WwOptionMenu is:
myapp.layout.option_menu.labelString: Style:
See Also
WwMenuItem, WwMenuBar, WwPopupMenu
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 additional information on attachment keywords, see "Form Layout: Attachments" 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.