Re: How do I capture the filename of an image dropped in an NSImageView?
Re: How do I capture the filename of an image dropped in an NSImageView?
- Subject: Re: How do I capture the filename of an image dropped in an NSImageView?
- From: Mark Lilback <email@hidden>
- Date: Wed, 17 Nov 2004 12:00:50 -0600
At 7:48 AM -0700 11/17/2004, Charles Crowley wrote:
In my application I store the filename of an image rather than the
image data itself. When a user drops an image on an NSImageView
there does not seem to be an obvious way to get the filename of the
image. Does anyone know how to do this?
Here is the subclass I use to get this information. And I agree, it
should be accessible. I've filed a bug report and I'd suggest you do,
too.
@implementation RTImageView
/*"
RTImageView is a subclass of NSImageView that will send out a
notification when an image file is dropped on view. The notification
will include the path to the file in the userInfo dict under the
key @"File".
"*/
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender {
BOOL val = [super performDragOperation: sender];
if (val) {
NSPasteboard *pboard = [sender draggingPasteboard];
NSString *plist = [pboard stringForType:
NSFilenamesPboardType];
if (plist) {
NSArray *files = [NSPropertyListSerialization
propertyListFromData:
[plist dataUsingEncoding: NSUTF8StringEncoding]
mutabilityOption:
NSPropertyListImmutable format: nil errorDescription: nil];
if ([files count] == 1)
[[NSNotificationCenter defaultCenter]
postNotificationName: RTImageDroppedNotification
object: self userInfo:
[NSDictionary dictionaryWithObject: [files objectAtIndex: 0]
forKey: @"File"]];
}
}
return val;
}
@end
--
__________________________________________________________________________
"The fetters imposed on liberty at home have ever
Mark J. Lilback been forged out of the weapons provided for
<email@hidden> defence against real, pretended, or imaginary
http://www.lilback.com/ dangers from abroad." -- James Madison
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden