(mac) application menu

Mike Hughes hughesmike2 at hotmail.com
Tue Nov 13 21:49:20 EST 2007

Hi Peter,

I'm not sure about Problem 2 but regarding Problem 1, you need to trap an AppleEvent in order for a standalone to perform some activities before quitting. For example, put this script in your main stack script and when theClass = "aevt" and theID = "quit", you can successfully trap the program before it quits. eg.

on appleEvent theClass,theID
  if theClass = "aevt" and theID = "quit" then
    -- do something
  end if
end appleEvent

Best Regards,


> Problem 1. Recipe: make a new stack. Use the menubuilder to make the  
> minimal menubar ("uMenubar" -- file, edit, help), and use the  
> autoscript builder to make the basic menupick scripts for each  
> button. Put "answer" commands in each menupick switch case to show  
> which menuitem you have selected, eg,
> ...
> case "open"
>    answer "you're trying to open something" as sheet
>    break
> case "quit"
>    answer "you're trying to quit" as sheet
>    break
> end switch
> Run it in the IDE -- fine, everything prompts the expected answer  
> dialogs, and you can't quit from the File->Quit menuitem, since the  
> switch statement intercepts it with a bare answer command. Now make  
> the stack into a standalone, setting the menubar of the stack to  
> "uMenubar" -- everything works as expected except that selecting  
> "quit " from the application menu results in a peremptory quit  
> -- no answer dialog saying "you're trying to quit". So I thought  
> maybe the message is actually not just "quit" but "quit " so I  
> changed the switch & case statements to read "case pWhich contains  
> "quit" -- but still no dialog, just a peremptory quit. Obviously the  
> system is catching the message and the rev engine in the app never  
> sees it. Same with the command-Q keyboard shortcut -- the  
> commandkeydown handler in the main stack script never sees it, though  
> it intercepts all the other keyboard menu equivalents.
> All of the above occurs in a simple test stack as prescribed above.  
> What is even stranger is that in the only slightly more complex stack  
> I have been trying to turn into an app (for collecting, sharing, and  
> printing recipes), I have the *opposite* problem -- when I turn it  
> into a standalone, selecting the "quit" item from the application  
> menu does **nothing at all**. Nada. Neither does the command-q  
> shortcut (which I scripted for), except the application menu hilites  
> briefly. The only way I can quit the app is to click the close box.  
> Which is fine, but the menu choice & the keyboard equivalent should  
> work too. Windows folks will expect to quit with the close box, but  
> Mac folks will be more likely to use the menu or the keyboard.
> How do I catch the quit message when the user selects it from the app  
> menu or does a command-q? -- I need to perform some housekeeping and  
> save operations, write the data to a file, etc. before the app  
> closes: something like saveDataToFile; cleanUpStuff; pass "quit". I  
> tried catching the closeStackRequest message but that never gets  
> triggered by the "quit" menuitem either, or by cmd-q.
> There is something fundamental that I don't understand about the  
> myApp>quit menu for a Mac standalone. Can someone explicate this?

Peek-a-boo FREE Tricks & Treats for You!

More information about the Use-livecode mailing list