Re: Quit Handler... What Am I Missing Here?
Re: Quit Handler... What Am I Missing Here?
- Subject: Re: Quit Handler... What Am I Missing Here?
- From: Axel Luttgens <email@hidden>
- Date: Sat, 14 May 2011 00:11:16 +0200
Le 13 mai 2011 à 22:57, S. J. Cunningham a écrit :
> [...]
>
> I'm sorry, but this just seems to be really bizarre behavior for something labeled "quit". I guess it's just me :-) I shudder to think what "continue" might mean :-)
>
> Might be an interesting defense:
>
> Prosecutor: "She said 'quit!' "
> Defendant: "Yes, but I wasn't done."
The latter is possibly quite relevant, provided the wording "quit" is given its right context.
"quit" is the name of an event; such an event may, for example, be sent:
- to an application when a user selects that application's "Quit" menu item,
- to all running applications when a user logs out.
It is up to the application to catch that event and to act accordingly; usually, the behavior is: cleanly terminate/stop what is was doing, perform any cleanup, and finally leave.
That is, "quit" isn't a command requiring to abruptly stop; it is an event providing the means to convey a user's intent. The application receiving such an event may act according to its own idiosyncrasies.
A regular AppleScript application performs the task initiated from its (explicit or implicit) run handler; once that task is done, the application leaves.
A stay open AppleScript application does the same, but doesn't leave; it then waits for an event targeted to it, performs the corresponding handler (if any), then waits again.
To terminate a regular applet is thus just a matter to put an end to the execution of its script code.
(hence the gotQuit variable in my skeleton code)
This isn't sufficient to have a stay open applet to terminate, since it would just... stay open. The application (ie the parent of the script) has to receive the quit event. But if the application's script has a "on quit" handler, that handler must then execute a "continue quit" statement so as to pass the event to the parent, unless one wants to prohibit the application to quit.
(see my reply to Ed)
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