将Automator操作拖放到AMWorkflowView

时间:2016-05-06 14:55:10

标签: macos cocoa drag-and-drop automator nspasteboard

2010年有人提交了一个错误: http://www.openradar.me/7582817

确实,如果您将自动播放器操作从Finder拖放到可编辑的AMWorkflowView,它就不会添加操作,但会添加一个新的"获取指定的查找器项目"动作。

我碰巧有NSTableView列出了一些可以从表格视图拖到其他视图的操作。在它的右边是AMWorkflowView,它应该是拖动目的地。一切都已实现并且工作正常,除了在这里,"获取指定的查找项目"添加操作而不是拖动操作本身。

打印AMWorkflowView's -registeredDraggedtypes输出此列表:

  

[" ApertureImageDataPboardType"," CalUUIDPasteboardType",   " AlbumDataListPboardType"," CorePasteboardFlavorType 0x6974756E",   " ABGroupsUIDsPboardType"," CorePasteboardFlavorType 0x4F69646E",   " NSFilenamesPboardType"," AutomatorActions",   " com.apple.Automator.RunScript.source"," Apple URL粘贴板类型",   " com.apple.mail.PasteboardTypeAutomator&#34 ;,   " ApertureFolderDataPboardType"," NSStringPboardType",   " CorePasteboardFlavorType 0x4870666C"," AutomatorVariables",   " ImageDataListPboardType","动作错误"," ABPeopleUIDsPboardType"]

似乎是" AutomatorActions" pboard类型是相关的,但由于缺乏文档,我一直无法弄清楚如何使我的应用程序工作。这有什么有用的信息吗?无法在Apple's Automator documentation中找到任何有意义的内容......并通过归档NSPasteBoard AMBundleActionNSKeyedArchiver来设置{{1}}的数据也不起作用。

1 个答案:

答案 0 :(得分:2)

没有记录,非法,使用风险自负:

- (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;
}