Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dragging from NSTableView to Finder



Hi, Andy...

You need to subclass NSTableView and override the following method:

- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal;

From this method, you should return whatever NSDragOperation masks you support. The default implementation returns NSDragOperationNone if "isLocal" is not true. This means that it won't support dragging outside of your application to any other application, including the Finder.

HTH,

-gtc


On Monday, July 7, 2003, at 07:29 PM, Andy Finnell wrote:

Hey all,

I have a simple NSTableView and I'm trying to make it so the user can drag files into my list view and drag files out of it into the Finder. I have the dragging from the Finder to my app working, but I can't get the Finder to accept my drags.

Here's what my tableView: writeRows: toPasteboard: code looks like:

- (BOOL) tableView: (NSTableView *) tableView writeRows: (NSArray *) rows toPasteboard: (NSPasteboard *) pboard
{
std::vector<ProjectFileRef>* files = mFiles;

NSMutableArray* fileNames = [NSMutableArray arrayWithCapacity: [rows count]];
for(int i = 0; i < [rows count]; i++) {
int rowIndex = [[rows objectAtIndex:i] intValue];
ProjectFileRef fileRef = (*files)[rowIndex];
NSString* absolutePath = ConvertCppStringToObjCString(fileRef.GetAbsolutePath());
[fileNames addObject: absolutePath];
}

[pboard declareTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:nil];
[pboard setPropertyList:fileNames forType:NSFilenamesPboardType];

return YES;
}

From the debugger I've verified that absolutePath is indeed a valid file path, but the Finder wants nothing to do with my drag. Its not even giving the drag feedback hilite. I can drag fine from within my application (within the same list view or from document to document).

I'm probably doing something stupid, but I can't see it. Any pointers?

Thanks,

-andy
_______________________________________________
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.




-gtc
_______________________________________________
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.

References: 
 >Dragging from NSTableView to Finder (From: Andy Finnell <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.