shurDownRequest handler works only first time

Barry Levine themacguy at macosx.com
Fri Sep 5 21:21:00 EDT 2003


Hugh,

The shutDownRequest is the method specifically designated as the way to 
handle the user selecting "Quit" from an OSX app menu. I quote from the 
docs:

> On OS X systems, the “Quit” menu item is part of the Application menu, 
> which is displayed by the operating system rather than by the 
> application. Because of this, choosing “Quit” on OS X systems does not 
> send a menuPick message, so you cannot handle quitting in a menuPick 
> handler.
>
> Instead, choosing “Quit” sends an Apple Event (class “aevt”, ID 
> “quit”) to the application. If you don’t intercept this Apple Event in 
> an appleEvent handler, Revolution sends a shutdownRequest message in 
> response to the Apple Event. To respond to the user choosing “Quit”, 
> handle either of these messages.
>
>   Tip:  For easiest cross-platform development, place all the code you 
> want to execute on quitting in a shutdownRequest handler.

So I placed the code to confirm whether the user wanted to quit with a 
shutDownRequest handler and the confirmation occurs only once - the 
first time the user selects "Quit" from the OSX app menu -or- uses 
"Command-Q". If the user cancels the quit, the program continues 
running. However, the next time the user attepts to quit, the app just 
quits with no confirmation. The shutDownRequest handler is not executed.

I have the menu in the same stack as the shutDownRequest handler. That 
stack is the only one open (although the "main" stack that contains the 
engine is hidden because it must stay running, of course). I tried 
moving the shutDownRequest handler to the "main" stack but it is then 
ignored completely.

What do you mean "trap on final stack closure"? Should I add a "start 
using" command of some kind? How have you implemented multi-stack 
(multi-file) apps? Must there always be a menu implemented for every 
stack? My first two stacks (a splash and a sign-in) have no menu 
specifically created for them. (And that's another issue because a 
splash screen shouldn't have an menu active anyway, right?

Any ideas are appreciated.

Regards,
Barry

On Friday, Sep 5, 2003, at 13:11 America/Denver, 
use-revolution-request at lists.runrev.com wrote:

> [snip]The > shutDownRequest handler is in that stack's stack script. 
> It works
>> the
>> first time it is called but it is ignored the second time; that app 
>> just
>> quite
>> without the shutDownRequest handler executing.
>
> Barry, have you tried putting the shutdownRequest handler in the 
> frontScript?
>
> It may be that, as in the case of closeStackRequest, shutdownRequest 
> is only
> actioned when the closeBox is actioned. If so, trap on final stack 
> closure.
--------------------------------------------------------
Barry Jay Levine
"The Mac Guy"

Macintosh Troubleshooting, System Engineering, Training,
AppleShare/OSX Server Setup, System Upgrades and Enhancements,
Custom Programming for Mac/Windows/Linux/Solaris

On-Site service for K20, Business, Consumer

Phone/VoiceMail: 915-581-1105
             Fax: 915-581-8167
           eMail: themacguy at macosx.com
--------------------------------------------------------




More information about the use-livecode mailing list