< Previous | Contents | Next >

Getting Menus to Do Stuff

One way to make a menu do things is to specify more about the menu items. Instead of items simply being the strings or atoms that will appear in the menu, items can be lists, each list with three elements (see Figure 13-3). The first element of each list is what

will appear in the menu; the second expression is what is evaluated, and the results of the evaluation returned, when the item is selected; and the third expression is the

expression that should be printed in the Prompt window when a mouse button is held down while the mouse is pointing to that menu item. This third item should be thought of as help text for the user. If the third element of the list is NIL, the system responds with Will select this item w hen you release the button.

image


Figure 13-3. Creating a Menu to do Things, then displaying it with the function

ADDMENU


Now when an item is selected from MY.MENU2, something will happen. When a mouse button is held down, the expression typed as the third element in the item’s

specification will be printed in the Prompt window. (See Figure 13-4.)


image


Figure 13-4. Mouse Button Held Down While Mouse Cursor SeIects NEXT.QUESTION


When the mouse button is released (i.e., the item is selected) the expression that was typed as the second element of the item’s specification will be run. (See Figure 13-5.)

image

Figure 13-5. NEXT-QUESTION Selected