-- card: 2302 from stack: in.1 -- bmap block id: 0 -- flags: 0000 -- background id: 3468 -- name: newmenu ----- HyperTalk script ----- on openCard global menu1, menu2 hide message put NewMenu("Beep","Once","Twice","(-","Boing/9") into menu1 put NewMenu("Visual","Effect 1","(Effect 2") into menu2 end openCard on closeCard global menu1, menu2 put DeleteMenu(menu1) into menu1 put DeleteMenu(menu2) into menu2 end closeCard on idle global menu1, menu2, lastTick if (the ticks-lastTick)>120 then put the ticks into lastTick ShowMenu menu1 ShowMenu menu2 end if pass idle end idle on doMenu which global menu1, menu2 if which is "Once" then beep 1 CheckMenu menu1,1,true else if which is "Twice" then beep 1 wait 4 beep 1 CheckMenu menu1,2,true else if which is "Boing" then flash 3 play "Boing" CheckMenu menu1,4,true else if which is "Effect 1" then push card visual effect dissolve to black EnableMenu menu2,1,false EnableMenu menu2,2,true pop card else if which is "Effect 2" then push card visual effect dissolve to white pop card EnableMenu menu2,1,true EnableMenu menu2,2,false else pass doMenu end if end doMenu -- part contents for background part 1 ----- text ----- NewMenu is an XFCN (external function) that allows you to add your own menus to a HyperCard stack. You may have up to eight menus with up to 15 items per menu. The number the NewMenu function returns is a reference number to the menu you just installed. You MUST have this number to delete or make changes to the menu later on! When you change userLevels, or select paint tools, or do anything to cause HyperCard to change the menu bar--your new menu will be erased from the menu bar. It is NOT gone from memory, just from the menu bar. To have it replaced automatically do the "on idle" routine shown below. This will make sure your menu is showing whenever you are in browse mode (on idle is not called when you're in button, field, or paint tools mode). Add an item like "(-" to insert a divider line between menu options. You may also end items with a slash letter (as is "An item/I") to add command keys. All this would generally be done in a stack's script as follows: on openCard -- display new menus global menu1, menu2 -- keep the "handles" to the menus in these globals put NewMenu("Beep","Once","Twice","(-","Boing/9") into menu1 if menu1 is 0 then answer("Unable to make menu 'BEEP'") with "Drat" put NewMenu("Visual","Effect 1") into menu2 if menu2 is 0 then answer("Unable to make menu 'Visual'") with "Drat" end openCard on closeCard -- delete the menus we've created using the globals saved in openStack global menu1, menu2 put DeleteMenu(menu1) into menu1 -- clearing global for safety put DeleteMenu(menu2) into menu2 end closeCard on idle -- call ShowMenu every so often just in case our menus vanished global menu1, menu2, lastTick if (the ticks-lastTick)>120 then -- gives better performance than on every iteration put the ticks into lastTick ShowMenu(menu1) ShowMenu(menu2) end if pass idle end idle on doMenu which -- get our menu items from doMenu before HyperCard does... global menu1, menu2 -- for CheckMenu and EnableMenu below if which is "Once" then beep 1 get CheckMenu(menu1,1,true) else if which is "Twice" then beep 1 wait 4 beep 1 get CheckMenu(menu1,2,true) else if which is "Boing" then play "Boing" get CheckMenu(menu1,4,true) else if which is "Effect 1" then push card visual effect dissolve to black pop card get EnableMenu(menu2,1,false) else pass doMenu -- Remember to pass on menu commands you don't trap! end doMenu Notice that if you want the menu to appear for all cards in the stack, you would place the NewMenu function in the stack's script and install it "on openStack" and remove it "on closeStack". If you wanted a menu to appear only for a certain background, the commands would be in that background's script and done "on openBackground" and "on closeBackground". And the commands to make a menu to appear only on a certain card would be done in that card's script "on openCard"/"on closeCard". -- part contents for background part 2 ----- text ----- NewMenu -- part contents for background part 4 ----- text ----- NewMenu(,<Item 1>,<Item 2>,...,<Item n>) *Menus for HyperCard™ -- part contents for background part 9 ----- text ----- XFCN -- part contents for background part 8 ----- text ----- Michael Long - Nine to Five Software Company