1
votes

In 2010 someone filed a bug : http://www.openradar.me/7582817

Indeed if you drag-and-drop an automator action from Finder to an editable AMWorkflowView, it doesn't add the action, but adds a new "Get specified finder items" action.

I happen to have an NSTableView listing a few actions that can be dragged from the table view to other views. On its right is an AMWorkflowView that is supposed to be the dragging destination. Everything is implemented and works fine, except that here too, "Get specified finder items" actions are added instead of the dragged actions themselves.

Printing the AMWorkflowView's -registeredDraggedtypes outputs this list :

["ApertureImageDataPboardType", "CalUUIDPasteboardType", "AlbumDataListPboardType", "CorePasteboardFlavorType 0x6974756E", "ABGroupsUIDsPboardType", "CorePasteboardFlavorType 0x4F69646E", "NSFilenamesPboardType", "AutomatorActions", "com.apple.Automator.RunScript.source", "Apple URL pasteboard type", "com.apple.mail.PasteboardTypeAutomator", "ApertureFolderDataPboardType", "NSStringPboardType", "CorePasteboardFlavorType 0x4870666C", "AutomatorVariables", "ImageDataListPboardType", "Action errors", "ABPeopleUIDsPboardType"]

It seems like the "AutomatorActions" pboard type is the relevant one, but due to lack of documentation I have been unable to figure out how to make my app work. Is there any useful information on this? Couldn't find anything meaningful in Apple's Automator documentation ... and setting the data of the NSPasteBoard by archiving an AMBundleAction with NSKeyedArchiver didn't work either.

1
Automator is also adding "Get specified finder items".Willeke

1 Answers

2
votes

Not documented, illegal, use at your own risk:

- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes
    toPasteboard:(NSPasteboard *)pboard
{
    [pboard clearContents];
    NSMutableArray *array = [NSMutableArray array];
    for (AMAction *action in [[self.arrayController arrangedObjects] objectsAtIndexes:rowIndexes])
    {
        NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
        [action writeToDictionary:dictionary];
        [array addObject:dictionary];
    }
    if ([pboard setPropertyList:@{@"Actions":array} forType:@"AutomatorActions"])
        return YES;
    return NO;
}