Re: Drag & Drop in an NSOutlineView
Re: Drag & Drop in an NSOutlineView
- Subject: Re: Drag & Drop in an NSOutlineView
- From: "Carter R. Harrison" <email@hidden>
- Date: Mon, 14 Mar 2011 15:38:23 -0400
Ack! I can't believe I missed that. The correct method to implement is:
- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
Once I changed the method declaration and a few of the implementation details drag and drop is now working! Thanks!
On Mar 14, 2011, at 3:33 PM, Quincey Morris wrote:
> On Mar 14, 2011, at 12:20, Carter R. Harrison wrote:
>
>> I'm having trouble getting drag and drop to work with an NSOutlineView. What I've done is below. The problem is that "tableView:writeRowsWithIndexes:toPasteboard" never gets called. I found a few people with the same issue and it seems that the cause of the problem is that I am using a custom cell that is a subclass of NSTextFieldCell, however I haven't been able to find a solution that fixes my problem.
>>
>> 1. Set the NSOutlineView's delegate and datasource outlets.
>> 2. In the datasource's awakeFromNib method I call "registerForDraggedTypes:" on the outline view.
>> 3. I implemented the following methods in my datasource:
>>
>> - (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteBoard *)pboard
>> - (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id < NSDraggingInfo >)info item:(id)item
>> - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id < NSDraggingInfo >)info proposedItem:(id)item proposedChildIndex:(NSInteger)index
>
> Why are you (trying to) use tableView:writeRowsWithIndexes:toPasteboard:? Why not outlineView:writeItems:toPasteboard:?
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden