Lingo Tutorial: Menus

READING: Installing Menus (Chapter 11, pages 390-393 in D8D)
Manual pages of the commands described here

File "menus.dir"

See how easy it is to add a menubar in your stand-alone application
(Unfortunately, menus will not work on the web page)

First, create a field containing your menu contents:

menu: @
About... | alert "Made in the USA"
menu: File
Quit/Q | quit
menu: Speed
Fast/1 | SetSpeed "Fast"
Medium/2 | SetSpeed "Medium"
Slow/3 | SetSpeed "Slow"
menu: Cast
Axe | SetCast "Axe"
Bart | SetCast "Bart"
Batman | SetCast "Batman"
menu: Cursor
Crossbar | cursor 3
Crosshair | cursor 2
I-beam | cursor 1
Pointer | cursor -1
Watch | cursor 4

Then, in a movie script install the menu:

on startMovie
  go to "Main Loop"
  installMenu (the number of cast "MainMenuBar")
  SetCast "Batman" -- default
  SetSpeed "Medium" -- default
end startMovie
--Activated by the menu: These two set-commands change the cast and speed.
on SetCast theCast
  sprite(2).castNum = cast(theCast).number
  set the checkMark of menuItem theCast of menu "Cast" = true 
  -- no alternative dot syntax available for the operation above yet:
  -- menu("Cast").menuItem(theCast).checkmark = true  does not work
end SetCast

on SetSpeed theSpeed global chaseSpeed if theSpeed = "Fast" then chaseSpeed = 40 if theSpeed = "Medium" then chaseSpeed = 25 if theSpeed = "Slow" then chaseSpeed = 10 UncheckAll("Speed", 3) set the checkMark of menuItem theSpeed of menu "Speed" = true end SetSpeed

on UncheckAll theMenu, numItems repeat with i = 1 to numItems set the checkMark of menuItem i of menu theMenu = false end repeat end UncheckAll

Now the menubar is installed. The rest is done by the HandleChase handler, as before.



Maintained By: Takis Metaxas
Last Modified: August 6, 2007