7.12. MENUS
91
7.12
Menus
Menus are constructed using three procedures menubar this contains a list of the
menus, menu this contains a string (the name of the menu) followed by menus
and menuitems, menuitem these contain strings labelling the menuitem. One
can also provide actions to be carried out when then menuitem is selected.
Below is a standard example of a File menu with a quit option that hides
the window. This also has GUI components for implementing a chat window
(although none of the needed actions are there!)
(define w
(window "Hello"
(menubar
(menu "File"
(menuitem "quit"
(action (lambda(e) (.hide w)))))
(menu "Help"
(menuitem "about")
(menuitem "documentation")))
(border
(north
(label "Chat Central" (HelveticaBold 40)))
(center
(textarea 10 50))
(south
(row
(label ">>")
(textfield "chat here" 30))))))
(.pack w)
(.show w)
Observe that each menu can have zero or more menuitems and can also contain
submenus.
7.13
Tags and Naming
As we will see it is often useful to be able to give names to components (for
example if we want to read from or write to a component, we must have a way
of refering to it).
The Tag mechanism provides a simple way to name and refer to objects.
A tagger is created using the following expression
(let ((t (maketagger)))
EXPR)
This creates a tagger t which can be used in the following expression. To
assign a name abc to an object X you use the syntax: