quitting is too complicated

J. Landman Gay jacque at hyperactivesw.com
Tue Jul 3 20:50:02 EDT 2007


Björnke von Gierke wrote:
> I seldom make applications, but I've run into these problems when I 
> tried to make my first os x standalone this year:
> 
> 1. command-q does never produce closestackrequest.

Right. CloseStackRequest is only sent when the user physically clicks 
the close box. It's the only way a script can know if the user does that.

> 2. closing the stack does leave the application running (as long as 
> there is any other stack in memory).

Yes. Other things that will prevent quitting are 1) if there are any 
pending messages in the queue, and 2) if there are any active drivers 
that need to be unloaded (like revUnloadSpeech.)

> 
> Therefore I had to use three messages (reposted below). Please someone 
> tell me that I missed the one correct message for intercepting quitting 
> and saving a stack :(

I usually manage things on closeStack, though it depends on the stack 
setup. For stacks that have open substacks that always need to be 
closed, I do something like this in the main stack script:

on closeStack
  if the target is not me then pass closeStack
  repeat for each line L in the substacks of this stack
    close stack L
  end repeat
  save this stack -- the main stack (optional)
  if the environment <> "development" then quit
end closeStack

Closestack is always sent, whether the user clicks the close box, 
chooses "quit" or "close" from a menu, or when a script issues a quit 
command. If your main stack has only a single card, you could use a 
closeCard handler instead.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list