Re: Very Irritating Open Handler
Re: Very Irritating Open Handler
- Subject: Re: Very Irritating Open Handler
- From: Axel Luttgens <email@hidden>
- Date: Sat, 02 Apr 2011 11:05:09 +0200
Le 31 mars 2011 à 21:32, Luther Fuller a écrit :
> I've been using a script for some time and decided to add an open handler to it so that the user could use Drag & Drop in addition to Select & Launch. Imaging my surprise when this script ...
>
> on open dropList
> if (count items of dropList) > 1 then error "You may Drag & Drop only one file."
> end open
>
> responded by opening a web page in Safari. I had Dragged & Dropped a .webloc file onto it.
> I want the script to ignore . webloc files ... and many other files that don't make sense to the script.
>
> [...]
>
> The problem occurs even with this very simple script ...
>
> on open dropList
> end open
>
> So it seems to be impossible to work-around it.
> This seems to be very undesirable buggy behavior. The open handler should not do this!
Hello Luther,
This seems to be a Finder thing; in fact, the open handler behaves correctly.
The general rule is: when dropping a selection of icons over an application's one, this happens thru the Finder; the Finder is supposed to build a list of references to the dragged items, then send an open event (odoc) to the target application.
Now enters the Finder's peculiar behavior (Stan already hinted a that behavior).
When dropping a single webloc, the Finder immediately sends an open location event (GURL).
When dragging at least a webloc and at least one item of another type, the Finder sends the open event with the list of dropped items without the weblocs; no open location event seems to be sent to the target application.
Fortunately, in your case, you aren't interested in the weblocs.
So, you may just trap the case of a single webloc:
on open L
-- do something with the list of aliases
end open
on open location WL
-- do something with the webloc if needed, or just trap the event
end open location
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