• 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
Drag-n-Drop in NSOutlineView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Drag-n-Drop in NSOutlineView


  • Subject: Drag-n-Drop in NSOutlineView
  • From: Bruce Sturgen <email@hidden>
  • Date: Fri, 9 Nov 2001 13:26:55 -0600

I think I am missing something. Not sure what, though...

I am trying to implement dnd within my NSOutlineView for reordering. Towards that end I implemented the outlineView:writeItems:toPasteboard message

-(BOOL)
outlineView:(NSOutlineView *)outlineView
writeItems:(NSArray*)items
toPasteboard:(NSPasteboard*)pboard {
// declare array of pasteboard data types
NSArray* types = [NSArray arrayWithObject: internalType];
// add the pasteboard type
[pboard declareTypes:types owner:nil];
// add the data
[pboard setString:[[items objectAtIndex:0] computePath] forType:FAVFavorite];
// affirm drag source
return YES;
}

I then implemented the following outlineView:validateDrop:proposedItem:proposedChildIndex message

-(NSDragOperation)
outlineView:(NSOutlineView*)outlineView
validateDrop:(id <NSDraggingInfo>)info
proposedItem:(id)item
proposedChildIndex:(int)index {
NSDragOperation rvalue = NSDragOperationNone;
NSPasteboard* pboard = [info draggingPasteboard];
NSArray* internalTypes = [NSArray arrayWithObject:internalType];

NSLog(@"Drop Types: %@", [pboard types]);

// check for internal operation
if ([pboard availableTypeFromArray:internalTypes]) {
rvalue = NSDragOperationPrivate;
}

return rvalue;
}

I have verified that the outlineView:writeItems:toPasteboard message is invoked and the resultant pasteboard data is accurate. However, the outlineView:validateDrop:proposedItem:proposedChildIndex message is never invoked and the dnd operation does not take place.

My first thought was that the issue was my pasteboard type. However, when I drag an item from the Finder onto my NSOutlineView, the validateDrop message is not invoked either.

Soooo, is there some super-secret message I need to use to tell the outline view to be a drop target? I thought implementing the validateDrop and acceptDrop messages was pretty much all I had to do (at least, that is how I read the NSOutlineViewDataSource protocol documentation).

Thanks for the help.

_________________________________
Bruce E. Sturgen
Think Different!
ICQ: 120302101 AIM: bsturg3n

-- From the New York Times, November 26, 1991--
"DOS computers manufactured by companies such as IBM, Compaq, Tandy, and
millions of others are by far the most popular, with about 70 million
machines in use worldwide. Macintosh fans, on the other hand, may note that
cockroaches are far more numerous than humans, and that numbers alone do not
denote a higher life form."


  • Follow-Ups:
    • All these newbie questions that are answered by documentation
      • From: "Erik M. Buck" <email@hidden>
    • Re: Drag-n-Drop in NSOutlineView
      • From: "Erik M. Buck" <email@hidden>
  • Prev by Date: Re: How to code a TableView into a CustomView?
  • Next by Date: Re: workspaces and capturing keystrokes
  • Previous by thread: Re: OSALoad/OSACompile block when machine is asleep
  • Next by thread: Re: Drag-n-Drop in NSOutlineView
  • Index(es):
    • Date
    • Thread