Re:Quitting an Applet II
Re:Quitting an Applet II
- Subject: Re:Quitting an Applet II
- From: email@hidden
- Date: Mon, 4 Dec 2000 18:22:12 -0500
On Mon, 04 Dec 2000 13:40:44 -0500, Carl West <email@hidden> asked,
>
Yesterday I wrote myself an alarm that on run pops up a dialog, I type
>
in a time, the time gets saved in a global and from then on, an 'on
>
idle' handler checks if that time is past and kicks off a repeat loop of
>
saying something and popping up a dialog with an "OK. I'm awake" button
>
giving up after 1.
>
>
The problem I have is one (or both) of these two things:
>
>
If I save it as a classic applet it quits as soon as I close the
>
type-in-the-time dialog. I don't know how to keep it open except with a
>
repeat loop instead of the 'on idle' handler.
>
>
If I save it as a stay-open applet I can't quit it from within (clicking
>
on the "OK. I'm awake" button) , I have to 'cmd-q'.
The stay-open applet and idle handler is the best way to do this. Otherwise,
you have to build your own idle loop by hand.
>
How do I either keep a classic applet open for a long time without
>
hogging the cpu, or close a stay-open applet from within?
To do it with a stay-open applet, use "tell me to quit" to signal to the applet
shell that it should exit when the handler in your script returns. Then return.
on idle
if (current date) > alarmTime then
display dialog "Get up" -- with your timeout and button stuff
if button returned of result is "OK. I'm awake" then quit
end if
return 60 -- idle loop goes back to sleep for 1 minute
end idle
Here, if you hit "OK. I'm awake", you send a "quit" event to the applet shell,
and the applet shell notes that its OK to quit. Then when you return from the
idle handler it actually quits.
--
Scott Norton Phone: +1-703-299-1656
DTI Associates, Inc. Fax: +1-703-706-0476
2920 South Glebe Road Internet: email@hidden
Arlington, VA 22206-2768 or email@hidden