Re: How do you get a stay-open applet to quit?
Re: How do you get a stay-open applet to quit?
- Subject: Re: How do you get a stay-open applet to quit?
- From: has <email@hidden>
- Date: Mon, 2 Jan 2006 16:57:00 +0000
Luther Fuller wrote:
>It is possible to have a script with only an 'idle' handler and containing no commands to tell it to quit. I had one of these showing in my Dock only moments ago while reading mail. It will quit only when I choose Quit from the Dock menu. But quit will fail unless there is a 'quit' handler to receive the 'quit' message. The 'quit' handler will look like this ...
>
>on quit
> -- optional stuff
> continue quit
>end quit
>
>Without this, it just keeps going and going ...
No, you don't need to define a quit handler in your applet script. Upon receiving a quit event, the applet shell will first look for one in the applet script and call it if it finds it, otherwise it will automatically forward the event to the applet's standard quit handler. This allows scripts to provide additional/alternate handling of quit events if they want; e.g. you could add a quit handler that displays a 'Are you sure you want to quit now?' confirmation dialog, and only executes the 'continue quit' statement if the user replies 'Yes'.
BTW/FYI, the 'continue' statement is used here to send events directly to the applet's standard event handlers, bypassing any handlers defined in the applet script. If you just wrote:
on quit
quit
end quit
the script's quit handler would just keep calling itself indefinitely (or until the call stack overflows, anyway), and the applet shell would never receive the instruction to quit.
Suffice to say, all this stuff makes a lot more sense when you've a basic understanding of how event-driven programming works. Most AS scripts follow the linear batch-processing model, whereas stay-open applets and Studio apps follow the event-driven model, and it's a lot easier to switch between the two mindsets when you understand the underlying principles.
has
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden