• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Table View drops
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
  • Follow-Ups:
    • Re: Table View drops
      • From: mmalcolm crawford <email@hidden>
References: 
 >Table View drops (From: April Gendill <email@hidden>)
 >Re: Table View drops (From: Scott Anguish <email@hidden>)
 >Re: Table View drops (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Re: Table View drops
  • Next by Date: Re: Table View drops
  • Previous by thread: Re: Table View drops
  • Next by thread: Re: Table View drops
  • Index(es):
    • Date
    • Thread