Accepting drag operations in an NSCollectionView subclass
Posted
by andyvn22
on Stack Overflow
See other posts from Stack Overflow
or by andyvn22
Published on 2010-05-02T16:39:03Z
Indexed on
2010/05/02
16:48 UTC
Read the original article
Hit count: 277
I've subclassed NSCollectionView and I'm trying to receive dragged files from the Finder. I'm receiving draggingEntered:
and returning an appropriate value, but I'm never receiving prepareForDragOperation:
(nor any of the methods after that in the process). Is there something obvious I'm missing here?
Code:
- (void)awakeFromNib
{
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
NSLog(@"entered"); //Happens
NSPasteboard *pboard;
NSDragOperation sourceDragMask;
sourceDragMask = [sender draggingSourceOperationMask];
pboard = [sender draggingPasteboard];
if ([[pboard types] containsObject:NSFilenamesPboardType])
{
NSLog(@"copy"); //Happens
return NSDragOperationCopy;
}
return NSDragOperationNone;
}
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
{
NSLog(@"prepare"); //Never happens
return YES;
}
© Stack Overflow or respective owner