Re: Using services to email file in document based app
Re: Using services to email file in document based app
- Subject: Re: Using services to email file in document based app
- From: Ken Thomases <email@hidden>
- Date: Fri, 11 May 2012 04:17:36 -0500
On May 11, 2012, at 2:09 AM, Gideon King wrote:
> I assumed that if I wanted to try this out, I should be able to do something like this in my NSDocument subclass:
>
> + (void)initialize {
> [NSApp registerServicesMenuSendTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, NSFileContentsPboardType, NSURLPboardType, NSFilesPromisePboardType, nil] returnTypes:nil];
> }
>
> - (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType {
> return nil;
> }
>
> - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray *)types {
> return NO;
> }
>
> (assuming that the "New Email With Attachment" service would take one of the pasteboard types I had specified).
That service is defined in Mail's Info.plist and it takes NSFilenamesPboardType.
> I then put breakpoints in the other two methods, but they were never called.
The Services docs say that the latter two methods must be on an NSResponder object, like a view or window. I recognize that the document is in the responder chain for action messages, but that may not suffice for this case. The docs also say:
"The validRequestorForSendType:returnType: message is sent along an abridged responder chain, comprising only the responder chain for the key window and the application object."
Regards,
Ken
_______________________________________________
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