Drag and drop display image and file path?
Drag and drop display image and file path?
- Subject: Drag and drop display image and file path?
- From: Henrietta Read <email@hidden>
- Date: Tue, 21 Apr 2009 16:03:47 -0700
Hi, I have an Image Well (NSImageView) in a window. I would like to display
a drag and drop image in the view and pass the file path on to my controller
object. In my 'MyImageView' object I'm doing:
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
if((NSDragOperationGeneric &
[sender draggingSourceOperationMask]) == NSDragOperationGeneric){
return NSDragOperationGeneric;
}
else{
return NSDragOperationNone;
}
}
and:
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSPasteboard *pboard = [sender draggingPasteboard];
if([[pboard types] containsObject:NSFilenamesPboardType]){
NSArray *files = [pboard propertyListForType:NSTIFFPboardType];
[self setImage:[files objectAtIndex:0]];
NSBeep();
}
return YES;
}
When I drag an image onto the view, I get the Beep but the image does not
display. Also how do I get the file path into my controller object? Is it
something to do with delegating performDragOperation into MyController?
Thank You.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden