Define Dynamic Menus
You can dynamically control the content of a drop-down or pop-up menus using ProcScript. First define a menu containing a menu item of type Dynamic Menu, then build the dynamic menu in the preDisplay trigger, and handle the use selection of an item in the option trigger.
Create a menu that will contain the dynamic menu. For more information, seeDefine and Use Menus.
-
Insert a menu item of type
Dynamic Menu at the desired location in the menu.
This acts as a placeholder for the dynamic menu and provides a location for the ProcScript required to generate the menu options and program their behavior.
-
Edit the preDisplay trigger of the dynamic menu placeholder.
Generate a nested associative list with the contents of the dynamic menu and insert it using the $inlinemenu ProcScript function.
For example:
- Define the first menu item by building a list of properties. For more information, see $inlinemenu.
- Add the menu item to the list of options
for the dynamic menu. Each menu option must have an identifier, which can be used in the
option trigger to define its behavior. In this case, it is
A
. - Build a list of properties for the second menu item.
- Add the second item to the list of options
for the dynamic menu as
B
.
; trigger preDisplay ; of dynamic menu placeholder variables string vMenuItem endvariables ;
Define a dynamic menu item putitem/id vMenuItem, "TYPE", "Option" putitem/id vMenuItem, "TEXT", "Option % A" putitem/id vMenuItem, "IMAGE","@ball.png" ;
Add it to the dynamic menu putitem/id $inlinemenu, "A", vMenuItem ;
Define another menu item putitem/id vMenuItem, "TYPE", "Option" putitem/id vMenuItem, "TEXT", "Option B" putitem/id vMenuItem, "CHECKED", "T" ;
Add it to the dynamic menu putitem/id $inlinemenu, "B", vMenuItem end; predisplay
-
Edit the option trigger of the dynamic menu placeholder.
Add ProcScript to determine which menu item was selected by the user and to perform the corresponding action.
For example, the following code displays a message indicating which menu item has been selected:
;trigger option ;Input parameter contains the identifier of the selected menu item params string strId : IN endparams ;Obtain the id of selected menu item and perform the associated action selectcase strId case "A" message/info "Option A selected" case "B" message/info "Option B selected" endselectcase end; select
- Compile the menu.