Download Simscript III Graphics Manual
Transcript
''Example24.sim
''Using a menu bar.
Preamble including the gui.m subsystem
begin class MyMenuBar
every MyMenuBar is a MenuBar, and
has a current_color, and
overrides the action
define current_color as a text variable
end
end
method MyMenuBar'action(event)
if current_color <> ""
let selected(find(current_color)) = 0 ''erase menu item check
always
let current_color = name(field(event))
let selected(find(current_color)) = 1
''show menu item check
''see which menu item was selected by comparing the field name
select case name(field(event))
case "black"
let color(Window) = Color'_black
case "white"
let color(Window) = Color'_white
case "red"
let color(Window) = Color'_red
case "green"
let color(Window) = Color'_green
case "blue"
let color(Window) = Color'_blue
case "cyan"
let color(Window) = Color'_cyan
case "magenta" let color(Window) = Color'_majenta
case "yellow" let color(Window) = Color'_yellow
case "exit"
return with _terminate
endselect
call display(Window)
return with _continue
end
main
''create window, dialog box and load it from a template
create Window, MyMenuBar
call display(Window)
let appearance(MyMenuBar) = Templates'find("menu bar")
file this MyMenuBar in form_set(Window)
call display(MyMenuBar)
''display the menu bar
''wait til user closes window or uses the exit menu
while visible(MyMenuBar) <> 0 and visible(Window) <> 0
call handle.events.r(1)
end
76