Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I enable Services which operate on selected Files and Folders
    primarykey
    data
    text
    <p>I am trying to enable Services which operate on selected <code>Files and Folders</code> similar to those which can be invoked in Finder.</p> <p>I have the following based on the <code>Services Implementation Guide</code> which works, but only for Text etc</p> <pre><code>+ (void)initialize { static BOOL initialized = NO; /* Make sure code only gets executed once. */ if (initialized == YES) return; initialized = YES; NSArray *sendTypes = [NSArray arrayWithObject:NSStringPboardType]; [NSApp registerServicesMenuSendTypes:sendTypes returnTypes:nil]; NSLog(@"initialize MyTableView"); } - (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType { NSLog(@"validRequestorForSendType %@%@", sendType, returnType); if ([sendType isEqual:NSStringPboardType]) { return self; } return [super validRequestorForSendType:sendType returnType:returnType]; } </code></pre> <p>How do I implement URL?</p> <p>The documentation states </p> <blockquote> <p>Your NSResponder object can register any pasteboard data type, public or proprietary, common or rare. If it handles the public and common types, of course, it has access to more services. For a list of standard pasteboard data types, see NSPasteboard Class Reference.</p> </blockquote> <p>There seems to be no corresponding pasteboard data type. I have tried <code>NSURL</code>, <code>NSURL class</code> <code>NSFilenamesPboardType</code> partially works, but does not show all the Services Finder does, and seems to belong to (OS X v10.5 and earlier)</p> <p><strong>Edit Clarification</strong></p> <p>I have been following the <code>Services Implementation Guide</code>, which seems to have 3 steps</p> <p>1.Registering Objects for Services</p> <pre><code>NSApp registerServicesMenuSendTypes: returnTypes: </code></pre> <p>2.Validating Services Menu Items</p> <pre><code>validRequestorForSendType:returnType: </code></pre> <p>3.Sending Data to the Service</p> <pre><code>writeSelectionToPasteboard:types: </code></pre> <p>I have got the first 2 to partially work (although I cannot get the same Menu I see in Finder when a File is selected in particular the <code>Files and Folders</code> )</p> <p>The 3rd seems to be the sticking point This seems to be supported for <code>NSTextView</code>, but deprecated for <code>NSObject</code></p> <p>I am really looking for some idea how to use Services for <code>Files and Folders</code> in the same way many other applications do.</p> <p><img src="https://i.stack.imgur.com/JCPQi.png" alt="Desired Services Menu"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload