use-revolution Digest, Vol 56, Issue 36

Peter Brigham pmbrig at gmail.com
Wed May 28 10:55:11 EDT 2008


On May 27, 2008, Lars Brehmer <larsbrehmer at mac.com> wrote:

> ...This brings me to a second question - in my standalone the close
> button saves all substacks , but apparently choosing quit in the MacOS
> menubar doesn't save anything. What must be done in order to have
> quitting from the menu bar save changes as well?
>
> Cheers,
>
> Lars

I had this problem also, and various people on the list suggested the  
solution. You have to cover all the ways you can quit from a  
standalone, on both platforms. Here's the thread I saved:

From: Mark Schonewille <m.schonewille at economy-x-talk.com>
Date: Fri, 16 Nov 2007 01:16:34 +0100
Re: Re: saving data in a standalone before quit
(Was Re: (mac) application menu)

Peter,

When you use the Quit menu item, Mac OS X sends an event to  
Revolution. You can catch this message with the AppleEvent handler or  
the shutdownRequest handler. On Mac OS X, I prefer to use the  
AppleEvent handler most of the time.

If you use either the AppleEvent handler or the shutdownRequest  
handler without a pass command, the application will not quit by  
itself (you can also lock messages and issue the quit command).

When you press command-Q, the Quit menu item should work just like  
when you use the mouse to select this menu item and you can catch the  
AppleEvent and shutdownRequest messages again. However, your script  
may catch the commandKeyDown message. If you don't pass this message  
with the pass command, your application may not quit.

There are versions of Revolution that don't pass the commandKeydown  
message because of a bug. There are also versions that don't pass the  
AppleEvent message.

If you are using Rev 2.8.1, problems with quitting are probably due  
to a script.

Best regards,

Mark Schonewille

--

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
http://www.salery.biz

Quickly extract data from your HyperCard stacks with DIFfersifier.  
http://differsifier.economy-x-talk.com


Op 15-nov-2007, om 23:08 heeft Peter Brigham het volgende geschreven:

Now, the other mystery -- I convert my stack to a standalone (now  
with the correct application name in the Mac manubar!) and when I  
select "quit <myApp> from the application menu, nothing happens.  
Anyone have any ideas what could cause this behavior? Per my previous  
experiments, this is probably *not* due to anything in my scripting,  
as it seems that the quit command is handled by the system. So what  
could be the problem?

-- Peter

********

From: Marty Knapp <martyknapp at comcast.net>
Date: Sat, 17 Nov 2007 11:04:20 -0800
On: How to use Revolution <use-revolution at lists.runrev.com>
Re: (mac) application menu

This was driving me crazy too. After messing around with it, I pieced
the following together and it's worked for me (I am using Rev 2.6.1):

on appleEvent pClass,pID,pSender  --I got this from Ken Ray's web site
   switch (pClass & pID)
   case "aevtquit"
     answer "Save changes?" with "Don't Save" or "Save"
     if it is "Save" then
       doSaveStuff
       pass appleEvent
     else pass appleEvent
     break
   default
     pass appleEvent
     break
   end switch

end appleEvent

on closeStackrequest
   Global homeStack
   if the short name of this stack is homeStack then
     answer "Save changes?" with "Don't Save" or "Save"
     if it is "Save" then
       doSaveStuff
     end if
   end if
   pass closeStackrequest
end closeStackrequest

on shutdownRequest --I only use this for Windows
   Global homeStack
   if the platform contains "Win" then
     if the short name of this stack is homeStack then
       answer "Save changes?" with "Don't Save" or "Save"
       if it is "Save" then
         doSaveStuff
       end if
     end if
   end if
   pass shutdownRequest
end shutdownRequest


Marty Knapp

******

Where to put the handlers depends on the structure of your stack  
system. You want them high enough up in the hierarchy to trap the  
messages no matter where the user is when the quit/close is  
triggered, but keep in mind that putting them in the main stack  
script will cause closeStackrequest to be called every time a  
subordinate stack closes.

-- Peter



More information about the use-livecode mailing list