HyperTalk Reference
Home » HyperTalk Reference » Commands

Note: This is a work in progress and will be formatting errors. Read more about the project on the home page.


doMenu itemName [without dialog] ¬
   [with keys ]
doMenu itemName, menuName ¬
   [without dialog] [with keys ]

The doMenu command performs the action specified by the item name and menu name just as if the user chose the item directly from the menu.

without dialog bypasses the dialog box that would normally appear after the commands Delete Stack and Convert Stack, and, when a background field is selected, after Cut Field and Clear Field.

with keys chooses the named menu command with the shift, option, and/or Command keys pressed.

To determine from a script which keys were specified, look at param(6) of the original command.

HyperCard sends the doMenu command as a message to the current card when the user selects a menu item. ItemName is the exact name of the menu item selected, and menuName is the exact name of the menu that contains the menu item. To handle the doMenu message, use this form:

on doMenu theItem,theMenu
end doMenu

Note: A doMenu handler can override a menuMessage.


doMenu "Next"

-- Add another Open Stack command:
put "Open Stack..." after menu "Go" with menuMsg "beep"
doMenu "Open Stack...", "Go" -- just beeps
doMenu "Open Stack...", "File" -- does an open stack

doMenu "Calculator" -- desk accessory from the Apple menu  
doMenu "Cut Field" without dialog -- with a bkgnd field selected

doMenu "Open Stack..." with shiftKey -- checks "New Window" checkbox
doMenu "Print Card" with shiftKey -- shows print dialog

on doMenu theItem,theMenu
  if theItem is "Quit HyperCard" then answer "Bye!" with "Later"
  pass doMenu -- all doMenu messages, including the quit, are passed
end doMenu

Demo Script

on mouseUp
   set cursor to watch
   doMenu "Background","Edit" -- view the background layer
   wait 45
   doMenu "Background","Edit" -- return to the card layer
 end mouseUp


A text expression that evaluates to the name of a menu item on one of HyperCard’s menus (or a menu created by the user).

For example:

"New Stack..."
"Stack Info..."

A text expression that evaluates to the name of one of HyperCard’s menus or of a menu created by the user.

For example:


Any return-separated list of built-in commands, user-defined handlers, or keywords that are part of a message or function handler.

put "Hello world"   -- built-in command
get total(field 1)  -- function call
global HelpInfo     -- keyword

Related Topics

« divide | HyperTalk Reference | drag »

Version 0.7b1 (March 24, 2022)

Made with Macintosh

Switch to Modern View