views:

21

answers:

1

Trying to get this to work, and not sure what I'm missing. The idea is to drop images on a NSTableView so that I can grab their paths and do some manipulations for them. I can get the drop to work for NSPastebouardTypeString, but I cannot for the life of me get it to register dragging PNGs from Finder into the tableview. What am I missing?

Relevent code:

- (void)awakeFromNib {
    [imageTableView registerForDraggedTypes:[NSArray arrayWithObject:NSPasteboardTypePNG]];
}

- (NSDragOperation)tableView:(NSTableView *)aTableView validateDrop:(id < NSDraggingInfo >)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)operation {
    NSLog(@"Validate Drop");
    return NSDragOperationEvery;
}

- (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id < NSDraggingInfo >)info row:(NSInteger)row dropOperation:(NSTableViewDropOperation)operation {
    NSLog(@"Accept Drop");
    return YES;
}
A: 

PNG files dragged from the Finder are not PNG data. They're files, which have their own pasteboard type. (Being files, you don't necessarily want them to be entirely loaded in memory in case of a drop, would you? :D)

10.4 gave you a NSArray of NSStrings as a NSFilenamesPboardType. 10.5 and later also provide you with an array of file: URLs as NSURLPboardType. Since you're using the older API, this document on 10.5- APIs applies (10.6 completely overhauls the pasteboard API to make it behave more like the iOS one).

millenomi
Ok. I misunderstood then. Should I _not_ be using `NSURLPboardType` or `NSFileNamesPboardType` in 10.6? I didn't see a comperable 10.6 api. Just the `writefiles:` method, which I understood as being for dragging out, as opposed to dropping in.
Gordon Fontenot