Download SIMGRAPHICS II User's Manual
Transcript
SIMGRAPHICS II User’s Manual Figure 8-16. Menu Bar After a menu bar is attached to a window and drawn it can receive input. This is done using the AcceptInput method: item := ASK menubar TO AcceptInput(); AcceptInput returns the menu option which was picked. You may perform various actions depending on which item was selected. CASE ASK item ReferenceName WHEN "Exit" : HALT; WHEN "Redo" : GoAgain; ... OTHERWISE END CASE; To receive a menu selection while a simulation is running you can do the following: 1. Create your own menu bar object and override the menu bar's BeSelected method: NEW(MyMenuBar); 2. Ask the menu bar object to load its graphic description from the library: ASK MyMenuBar TO LoadFromLibrary(lib, "MenuBar"); 3. Attach the menu bar to the window: ASK window TO AddGraphic(MyMenuBar); 4. Display the menu bar and initiate interaction. item := ASK MyMenuBar TO AcceptInput( ); 5. Start the simulation: StartSimulation. 6. The BeSelected method of MyMenuBar will be called whenever there is a menu selection, and the LastPicked field of the menu bar will point to the item which was selected. The BeSelected method should be overridden to look something like this: 130