Re: Very Irritating Open Handler
Re: Very Irritating Open Handler
- Subject: Re: Very Irritating Open Handler
- From: Axel Luttgens <email@hidden>
- Date: Tue, 05 Apr 2011 10:08:29 +0200
Le 4 avr. 2011 à 23:01, Luther Fuller a écrit :
> On Apr 4, 2011, at 3:40 PM, Axel Luttgens wrote:
>
>>> So, in the case of a .webloc, the open location handler gets invoked as announced; this means that if you don't insert a:
>> continue open location
>> statement within that handler, the event would indeed be trapped.
>>
>> Now, I'm not sure whether issuing an error statement from within the handler is a good idea; what happens without that statement?
>
> The 'open location' handler dies after doing the displays. Period.
Of course, the same way the 'open' handler "dies" after having performed its job.
> I tried both 'return' and 'error' at the end to diagnose the behavior.
> No change.
An explicit 'return' statement won't differ from an implicit one.
And why would you want to throw an error?
> I'm not sure that 'open location' is a valid handler name, but the arrival of a .webloc in the 'open' handler seems to call it.
Because it's a valid handler name. ;-)
> (But you can't write 'my open location ...' because 'open location' seems not to be a valid handler name.)
>
> I think there is no work-around for this ... the open handler is now just a pomme de rue.
You said you wanted to filter out .weblocs anyway, as well as other kinds of items; the Finder does it for you for the .weblocs and, moreover, you have the opportunity to avoid to launch the default web browser.
Perhaps didn't I correctly understood what you exactly want to do? Please let me know.
Anyway, here's follows a sample code for a droplet that works as announced here:
-- This one will be invoked when at least one non .webloc item is
-- dropped (any .webloc is then filtered out by the Finder).
on open dropList
handleDroppedItems(dropList)
end open
-- This one will be invoked when one or more .webloc items are dropped.
-- Only one text argument is passed by the Finder (the first selected
-- .webloc item)
on open location WL
handleDroppedItems({WL})
-- Uncomment the following if you wants to have the default browser
-- open the web page...
--continue open location WL
end open location
on handleDroppedItems(L)
repeat with dropItem in L
if class of dropItem is text then
display dialog "Sorry, I don't want you to drop .weblocs only!"
else
display dialog "You dropped: " & (dropItem as text)
end if
end repeat
end handleDroppedItems
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