Scripting & Custom Interface
Steve Mills
smills at multi-ad.com
Wed Sep 20 09:38:30 CDT 2006
On Sep 20, 2006, at 08:22:27, chris denesha wrote:
> At 06:45 PM 9/19/2006 -0400, you wrote:
>> Hi Steve,
>>
>> It's been a while, but since I'm in a scripty mood today...
>>
>> Is there any way to prevent a User Palette from closing as a
>> result of the
>> user clicking a Cancel button in a dialog brought up by another
>> part of the
>> same script? I have a palette that stays open all the time as a
>> launch pad
>> for other actions linked to buttons within it. In this case, if
>> multiple
>> docs are detected, a warning dialog appears, but if you change
>> your mind and
>> hit Cancel, the launch pad palette disappears as well.
>
> I haven't played with user palettes yet but I can think of two
> possibilities from a programming standpoint - have you experimented
> with them?
>
> 1) Use code to check for the response from the dialog box - if it
> is Cancel (or perhaps if it isn't OK, depending on whether you have
> a default button) and either prevent the palette close or reopen it
>
> 2) Trap an event that tells you it is about to close - looking in
> the dictionary there is a 'request to close' callback event under
> Custom Interface with a description that might help.
Both sound like viable options, but there are 2 different things
happening; clicking the close box, and clicking the Cancel button in
the warning dialog (which is falling through and telling the entire
script to cancel, I believe).
If you're using "display dialog" for the warning, you can trap the
Cancel button like so:
try
display dialog "bob" buttons {"Cancel"} default button "Cancel"
on error err number num
if num is -128 then
say "cancelled"
else
--Pass on other errors:
error err number num
end if
end try
Or if you're using a "user dialog" for the warning, you'll get the
clicked button returned from "run dialog modally".
But in the end, installing a "request to close" handler sounds like
the thing to do for handling the palette's close box.
_________________________________________________________
Steve Mills Me: 952-401-6255
Senior Software Architect MultiAd
smills at multiad.com www.multi-ad.com
More information about the Creator
mailing list