Re: NSURLPboardType broken for dropping files in Panther....?
Re: NSURLPboardType broken for dropping files in Panther....?
- Subject: Re: NSURLPboardType broken for dropping files in Panther....?
- From: Rob In der Maur <email@hidden>
- Date: Tue, 4 Nov 2003 16:59:22 +0100
On Nov 4, 2003, at 6:27, mmalcolm crawford wrote:
>
On Nov 3, 2003, at 7:25 PM, Kurt Marek wrote:
>
>
> Thanks for the app. It doesn't work on my system running 10.3.
>
> Dragging a file from the Finder to the imageView does nothing.
>
> Dragging a link from Safari works great. I think NSURLPoardType for
>
> files in the Finder is broken under Panther as was suggested by Rob.
>
>
>
Umm, so check for NSFilenamesPboardType (and if you get *one*, turn
>
that into an URL)?
>
<http://homepage.mac.com/mmalc/CocoaExamples/ImageURLDragAndDrop.zip>
>
(updated).
That's coding around the fact that NSURLPboardType definitely seems to
be broken in Panther. In my code I had:
- (NSDragOperation)tableView:(NSTableView *)aTableView
validateDrop:(id <NSDraggingInfo>)info
proposedRow:(int)row
proposedDropOperation:(NSTableViewDropOperation)operation
{
... (figuring out whether I was dragging from inside the table
itself or from outside of it)
... (when outside, e.g. from the Finder)
// we're dropping from outside the table...
NSPasteboard *pboard = [info draggingPasteboard];
if (logFlag) NSLog(@"LinksTableDataSource ->
tableView:validateDrop:proposedRow:proposedDropOperation: Pasteboard
contains: %@", pboard);
NSURL *url = [NSURL URLFromPasteboard:[info
draggingPasteboard]];
if (logFlag) NSLog(@"LinksTableDataSource ->
tableView:validateDrop:proposedRow:proposedDropOperation: Dropped URL:
%@/%@", [url absoluteString], [url absoluteURL]);
[aTableView setDropRow:[aTableView numberOfRows]-1
dropOperation:NSTableViewDropAbove];
return NSDragOperationCopy;
}
and
- (BOOL)tableView:(NSTableView*)aTableView
acceptDrop:(id <NSDraggingInfo>)info
row:(int)row
dropOperation:(NSTableViewDropOperation)op
{
int originalRow;
if (logFlag) NSLog(@"LinksTableDataSource ->
tableView:acceptDrop:row:dropOperation:...");
// get an array of the pasteboard types
NSArray *typesArray=[[info draggingPasteboard] types];
// if whatever we have on the pasteboard is of type
LINKS_ENTRY_DRAG_TYPE
// we can assume it is a move of one of the entries to another
position
if ([[typesArray objectAtIndex:0]
isEqualToString:LINKS_ENTRY_DRAG_TYPE]==YES) {
originalRow = *((int *) [[[info draggingPasteboard]
dataForType:LINKS_ENTRY_DRAG_TYPE] bytes]);
if (logFlag) NSLog(@"LinksTableDataSource -> moving row %d to
new position %d...", originalRow, row);
// allocate a new mutable array
NSMutableArray *entryLinks = [[NSMutableArray alloc] init];
// add existing array to it
[entryLinks addObjectsFromArray:[[[self controller]
displayEntry] links]];
Link *moveLink = [entryLinks objectAtIndex:originalRow];
if (logFlag) NSLog(@"LinksTableDataSource -> we move link with
description %@...", [moveLink linkDesc]);
// remove this link from the array
[entryLinks removeObjectAtIndex:originalRow];
// and insert the link into its new position
[entryLinks insertObject:moveLink atIndex:row];
// set the links array associated with this displayEntry to the
new links array
[[[self controller] displayEntry] setLinks:entryLinks];
// release the allocated links array
[entryLinks release];
// reload table
[aTableView reloadData];
}
else {
// so this is a drag from outside the table (e.g. the Finder)
// allocate a new array
NSMutableArray *entryLinks = [[NSMutableArray alloc] init];
// add existing array to it
[entryLinks addObjectsFromArray:[[[self controller]
displayEntry] links]];
// get the url from the pasteboard
NSURL *url = [NSURL URLFromPasteboard:[info
draggingPasteboard]];
// get the string from the URL
NSString *urlString = [url relativeString];
// allocate a new link object and set its members
Link *newLink = [[Link alloc] init];
[newLink setLinkDesc:urlString];
[newLink setLinkURL:url];
// add the new link to the array
[entryLinks addObject:newLink];
if (logFlag) NSLog(@"Added the link with description %@ to the
links array of %@...", [newLink linkDesc], [[[self controller]
displayEntry] entryName]);
// release the new link
[newLink release];
// set the links array associated with this displayEntry to the
new links array
[[[self controller] displayEntry] setLinks:entryLinks];
// release the allocated links array
[entryLinks release];
// reload the table
[aTableView reloadData];
}
return YES;
}
This all worked flawlessly under Jaguar. If I dropped a JPEG onto the
table, I would see the JPEG image in the table. If I dropped a
QuickTime movie on the table, I could see the Quicktime details, as in
this picture (I add icons and do font handling to the table in my
table's delegate....)
But now it doesn't work anymore. And I really would like to know
whether this is because this is broken in Panther or this change in
functionality is deliberate.
Cheers,
Rob
- Rob In der Maur
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.