Thanks Ken, moving it to my window controller got my validRequestorForSendType 
called, but the services menu now shows up with just one item: "Notebook 
Clipping Setup".

So as it stands, this is my code:

+ (void)initialize {
    [NSApp registerServicesMenuSendTypes:[NSArray 
arrayWithObject:NSFilenamesPboardType] returnTypes:nil];
}

- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString 
*)returnType {
    if ([sendType isEqualToString:NSFilenamesPboardType]) {
        NSDocument *d = [self document];
        if ([d fileURL] && ![[self window] isDocumentEdited]) {
            return self;
        }
    }
    return nil;
}

- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray 
*)types {
    if ([types containsObject:NSFilenamesPboardType]) {
        NSDocument *d = [self document];
        if ([d fileURL] && ![[self window] isDocumentEdited]) {
            [pboard setString:[[d fileURL] path] forType:NSFilenamesPboardType];
            return YES;
        }
    }
    return NO;
}

With this type registeredI see that the validRequestorForSendType is called 
asking for the following types:
com.apple.flat-rtfd
dyn.agu8y6y4grf0gn5xbrzw1gydcr7u1e3cytf2gn
NeXT Rich Text Format v1.0 pasteboard type
NeXT RTFD pasteboard type
NSFilenamesPboardType
NSStringPboardType
public.rtf
public.utf8-plain-text

If I have a dirty document, or one that has just been created, the services 
menu is empty as expected. However, when I have a saved document selected, the 
only item that shows up is the notebook clipping setup.

Seeing as the service I want to be available is specified in the mail 
info.plist using the NSFilenamesPboardType, I'm not sure where else the problem 
could lie.

Anyone have any other suggestions?


Thanks

Gideon



On 11/05/2012, at 7:17 PM, Ken Thomases wrote:

> 
> 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to