I have a subclass of NSView that registers drag and drop files in the init method, for example:
[self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
Dragging and dropping works fine, but if I add this view with the same frame, it no longer works. I assume that subview blocks the drag event to go to the super view. Can i avoid this? Thanks
In addition, I know that I am asking two questions, but I do not want to create a new topic just for this: when I drag, my cursor does not change to a + sign, as with other drags, How do I do this? Thanks again.
UPDATE: Here, as I created it in my IB: 
DrawView is a custom class that I talked about about being registered for draggedtypes. And viewing the image is just a preview, I dragged the image from the multimedia section ... If that helps, here is my corresponding code for DragView:
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender { return NSDragOperationCopy; } - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender { NSPasteboard *pboard; pboard = [sender draggingPasteboard]; NSArray *list = [pboard propertyListForType:NSFilenamesPboardType]; if ([list count] == 1) { BOOL isDirectory = NO; NSString *fileName = [list objectAtIndex:0]; [[NSFileManager defaultManager] fileExistsAtPath:fileName isDirectory: &isDirectory]; if (isDirectory) { NSLog(@"AHH YEA"); } else { NSLog(@"NOO"); } } return YES; }
user635064
source share