• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Quit Handler... What Am I Missing Here?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quit Handler... What Am I Missing Here?


  • Subject: Re: Quit Handler... What Am I Missing Here?
  • From: Axel Luttgens <email@hidden>
  • Date: Thu, 12 May 2011 12:25:40 +0200

Le 12 mai 2011 à 02:09, Stockly, Ed a écrit :

> [...]
>
> Here's something that works, but your app must be a stay open app.
>
> ------
> on run {}
>    display alert "Starting Up"
> end run
>
> on quit {}
>    display alert "About to Quit!"
>    continue quit
>    display alert "Trying to quit!"
>    return
> end quit
>
> on idle
>    return 1
> end idle
> ------
>
> Not every script can be structured with an idle handler, but if yours can,
> this will work.

Hello Ed,

Above script may be simplified so as to focus on the true point of interest:

	on run
		display alert "Starting Up"
	end run

	on quit
		display alert "About to Quit!"
		continue quit
		display alert "Trying to quit!"
	end quit

The purpose of a stay open app is, well, to stay open.
That is, instead of quitting after having performed its tasks as a regular app would do, it waits for subsequent events.

One of those events is the "quit" event.
Either there is no quit handler, and the quit event is immediately passed to the parent (the current application).
Or there is a quit handler, and that handler is invoked.

In the latter case, the quit event is trapped and won't reach the parent.
Unless the quit handler executes a "continue quit" statement, in which case the quit event is passed to the parent; the current application now has the opportunity to register that it should quit as soon as all pending tasks are performed.


> Not sure why the "Trying to quit" alert displays.

Because the quit handler, being a pending task, has to be entirely executed.


HTH,
Axel

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: Quit Handler... What Am I Missing Here? (From: "Stockly, Ed" <email@hidden>)

  • Prev by Date: Re: Quit Handler... What Am I Missing Here?
  • Next by Date: What is the System language
  • Previous by thread: Re: Quit Handler... What Am I Missing Here?
  • Next by thread: A Note on the Quit Handler
  • Index(es):
    • Date
    • Thread