Re: Apple event for "open contents": re-entry and multiple qualifying services
Re: Apple event for "open contents": re-entry and multiple qualifying services
- Subject: Re: Apple event for "open contents": re-entry and multiple qualifying services
- From: Daryle Walker <email@hidden>
- Date: Sat, 13 Sep 2014 01:47:27 -0400
On Sep 13, 2014, at 12:09 AM, Ken Thomases <email@hidden> wrote:
> On Sep 12, 2014, at 12:37 PM, Daryle Walker <email@hidden> wrote:
>
>> I’m looking at <https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ScriptableCocoaApplications/SApps_handle_AEs/SAppsHandleAEs.html#//apple_ref/doc/uid/20001239-1121328>.
>>
>> 2. Doing the action involves calling the Carbon handler. The legacy docs mention calling the service that can handle the appropriate data type. But the prose acts like either you have an appropriate handler or you don’t. But I’ve been looking over the Services docs, and you can have multiple services, even multiple handlers for the same data type! The doc writers, or worse the API writers, sloppily didn’t consider that case. Is there a secret dictionary key to indicate which service to use? Do the system pick the first one? Or would the writers punt and insist that programmers forfeit the automatic handling and write an Apple event override for the open-contents event? (And Apple’s writers need to add that case.)
>
> Well, it will limit itself to services which take the data type and have no return data type. You're right, though, that that still could mean multiple services qualify. I'm not aware of any built-in way to tell the system which service it should use when there is ambiguity.
>
> (I found this in the Carbon-Dev list archives: <https://lists.apple.com/archives/carbon-dev/2006/Jan/msg00932.html>. The email is hidden to foil spam bots and I'm not familiar with the author's name, but the language suggests it's from an Apple engineer. It says that the first qualifying service in the Info.plist will be used. Take that for what it's worth.)
Since I’ve been subscribed to the Carbon and Cocoa dev lists since I got an iTools account in the late 1900s, I searched for the message with Mail. (Thank you, IMAP.) I found it and, yes, the author has an @apple.com e-mail address.
Since that post was written, the send and return type lists are now optional, and they can take UTI strings. I guess I would need to add a send-type list. I wonder if I can use (relatively) base UTIs for types. For instance, using public.image instead of listing both public.png and public.jpeg. If so, I’d use a public.content wildcard since I can take (almost) everything. I just hope the actual items will have their actual UTIs, and not the base type. I also would have to list my special handler for URLs first.
> So, when there's no documented solution, you should not rely on getting the behavior you want (or any specific behavior). You should take control and make sure that what you want done is done.
>
> It's not terribly hard to install your own handler for the "open contents" event and do the right thing. You could pick a service and invoke it, but that seems rather roundabout. You are the one who supplies the handler for the service, so you might as well just invoke it directly.
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden