Re: Accepting image drags from Safari & Firefox
Re: Accepting image drags from Safari & Firefox
- Subject: Re: Accepting image drags from Safari & Firefox
- From: Andreas Mayer <email@hidden>
- Date: Mon, 6 Jun 2005 03:14:36 +0200
Am 3. Jun 2005 um 18:25 Uhr schrieb Jonathan del Strother:
I'm having trouble finding a way that reliably works for all
situations (eg when the image is surrounded by link tags, I get the
link destination rather than the image URL)
I don't see this problem.
How would you get a link from the pasteboard if you are looking for
an image?
This seems to work for me:
if ([[pboard types] containsObject:NSTIFFPboardType]) {
pictureData = [pboard dataForType:NSTIFFPboardType];
newImage = [[[NSImage alloc] initWithData:pictureData]
autorelease];
} else if ([[pboard types] containsObject:NSPICTPboardType]) {
pictureData = [pboard dataForType:NSPICTPboardType];
newImage = [[[NSImage alloc] initWithData:pictureData]
autorelease];
} else if ([[pboard types] containsObject:NSFilenamesPboardType]) {
NSArray *files = [pboard
propertyListForType:NSFilenamesPboardType];
if (sourceDragMask & NSDragOperationGeneric) {
imagePath = [files objectAtIndex:0];
if (imagePath) {
imagePath = [[NSFileManager defaultManager]
resolveAliasFile:imagePath];
}
}
}
Andreas
_______________________________________________
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