Building a Menu Structure Building a Menu Structure The strategy for implementing a menu is: 1. Declare the top-level bar menu. 2. Start a loop monitoring event 14 (menu selection). 3. When event 14 is detected, check to see if the mouse event was on the top-level bar menu or on a pull-down option. 4. If the event was a top-level menu selection, then display the proper pull-down options. 5. If the event was a pull-down selection, use nested CASE structures to take appropriate action based on the selections made to the top-level menu and its corresponding pull-down menu. Menu Example This code segment will implement a menu structure for a window open on glun:
; Set the top-level menu bar and enable monitoring of events FSET (glun) "/menu 'Menu 1' 'Menu 2' 'Menu 3'" FSET (glun) "/event button menu" ; Define the strings for the pull-down menus $menu[1] = "'Item 1-1' 'Item 1-2'" $menu[2] = "'Item 2-1' 'Item 2-2' 'Item 2-3'" $menu[3] = "'Quit'" ; Set variable for event to be monitored wn.e.menu = 14 ; Start the processing loop quit = FALSE DO GETEVENT (glun) event[] IF event[0] == wn.e.menu THEN ;The menu event (14) has two components; a button-down component ; corresponding to a click on a menu bar selection, and a ; button-up component corresponding to the pull-down selection ; made when the button is released.
; After the first component (pointer down on the menu bar), ; event[1] will be 0 and event[2] will have the number of the ; menu bar selection. ; Check to see if event[1] is 0, indicating a top-level menu select IF event[1] == 0 THEN ; Use the value in event[2] to select a pull-down menu FSET (glun) "/pulldown", event[2], $menu[event[2]] ; Else, execute the appropriate code for each menu selection ELSE ; If event[1] is not 0, then the button has been released on a eV+Language User's Guide, v2.x, 18318-000 Rev A Page 167