检测拖动项目的路径

时间:2012-02-07 13:20:58

标签: cocoa

如何检测拖动项目(文件或文件夹)的路径?

当这条路径掉落在某个区域时,是否可以抓住它?

1 个答案:

答案 0 :(得分:2)

请参阅Drag and Drop Programming Topics - Receiving Drag Operations了解相关信息。删除文件后,您将从粘贴板接收一系列文件。摘自示例:

- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender {    
    NSPasteboard *pboard;    
    NSDragOperation sourceDragMask;

    sourceDragMask = [sender draggingSourceOperationMask];    
    pboard = [sender draggingPasteboard];

    if ( [[pboard types] containsObject:NSFilenamesPboardType] ) {
        NSArray *files = [pboard propertyListForType:NSFilenamesPboardType];
        // ...