Re: Table View drops
Re: Table View drops
- Subject: Re: Table View drops
- From: Scott Anguish <email@hidden>
- Date: Fri, 17 Oct 2003 03:20:35 -0400
On Oct 17, 2003, at 3:15 AM, demo monkey wrote:
On Oct 16, 2003, at 10:59 PM, Scott Anguish wrote:
This is pulled from an NSTableView subclass that I have that only
accepts strings on the pasteboard.
Hmph, well, at one time it accepted NSURLs as well...
Quiet Demo Monkey.
Actually, the URLs are strings in the app that you're talking about.
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
{
In email April asked if you'd just check the extension.. and I
realized that this wouldn't be the best way to do it.. you'd need to
also take into account the HFS types that your app supports.
A better solution may be to to use NSHFSTypeOfFile(fullFilePath) to
convert everything to a format that you can then check in the array...
if it returns nil, then use the pathExtension
(written in Mail, not tested)..
- (BOOL)isFileValid:(NSString *)fullFilePath {
NSArray *supportedFileTypes = [NSArray arrayWithObjects: @txt,
@text,
NSFileTypeForHFSTypeCode( TEXT ), nil];
NSString *fileTypeToCheck=NSHFSTypeOfFile(fullFilePath);
if (!fileTypeToCheck) {
fileTypeToCheck=[fullFilePath pathExtension];
BOOL fileIsSupported=[supportedFileTypes contains:fileTypeToCheck];
return fileIsSupported;
}
http://developer.apple.com/documentation/Cocoa/Conceptual/
LowLevelFileMgmt/Concepts/HFSFileTypes.html#//apple_ref/doc/uid/
20000779
** Note that these are methods implemented in the tableview's
delegate. **
Hah! No, they're not. The dragging methods are implemented in the
DATASOURCE!!! Do you not remember that from last week? Sit down and
move the mouse.. :-)
_______________________________________________
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.