Re: Table View drops
Re: Table View drops
- Subject: Re: Table View drops
- From: Scott Anguish <email@hidden>
- Date: Fri, 17 Oct 2003 01:59:19 -0400
On Oct 17, 2003, at 12:49 AM, April Gendill wrote:
In a number of programs (iTunes for instance) you can drop files into
a table view. In doing so, you are limited to the types of files that
the application can handle. Is there a way through the pasteboard to
limit the files types that can be dropped or is it something that must
be done programatically? In other words, something like checking the
file name for a certain extension or using the fileManager to check
the type?
You can advertise the type of pasteboards that you support by
registering with the allowed types
- (void)awakeFromNib {
[self registerForDraggedTypes:[NSArray arrayWithObjects:
NSStringPboardType, nil]];
}
This is pulled from an NSTableView subclass that I have that only
accepts strings on the pasteboard.
You can refine the restriction further by implementing
-tableView:validateDrop:proposedRow
Again, this is pulled from the same app.. the validateURLForASIN:
method looks at the URL, and then determines if it's in the format that
I expect. If it is, then I return NSDragOperationCopy, otherwise
NSDragOperationNone.
You'd check the file types of the dragged in files in place of this...
- (NSDragOperation)tableView:(NSTableView*)tableView
validateDrop:(id <NSDraggingInfo>)info
proposedRow:(int)row
proposedDropOperation:(NSTableViewDropOperation)operation
{
NSPasteboard *pboard;
pboard = [info draggingPasteboard];
BOOL _asin;
_asin=[SWASINSearchRequest validateURLForASIN:[pboard
stringForType:NSStringPboardType]];
if (_asin)
return NSDragOperationCopy;
return NSDragOperationNone;
}
_______________________________________________
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.