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

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:32:44 -0400

The custom cell I'm using is a modification of "ImageAndTextCell" from the DragNDropOutlineView sample project.  In that class they have some comments that describe how "hitTestForEvent:inRect:ofView:" works.  It's my understanding that if I return anything other than NSCellHitTrackableArea a drag should be initiated.  Here is my implementation of that method and I'm still not having any luck:

- (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect)cellFrame ofView:(NSView *)controlView
{
    return NSCellHitContentArea;
}


On Mar 14, 2011, at 3:25 PM, Corbin Dunn wrote:

> Your custom cell needs to properly implement:
>
> - (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect)cellFrame ofView:(NSView *)controlView NS_AVAILABLE_MAC(10_5);
>
> See the header for details or the AnimatedTableView demo.
>
> --corbin
>
> On Mar 14, 2011, at 12:20 PM, 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
>>
>> Any help is greatly appreciated!
>> _______________________________________________
>>
>> 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
>

_______________________________________________

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

References: 
 >Drag & Drop in an NSOutlineView (From: "Carter R. Harrison" <email@hidden>)
 >Re: Drag & Drop in an NSOutlineView (From: Corbin Dunn <email@hidden>)

  • Prev by Date: Re: Drag & Drop in an NSOutlineView
  • Next by Date: Re: Drag & Drop in an NSOutlineView
  • Previous by thread: Re: Drag & Drop in an NSOutlineView
  • Next by thread: Re: Drag & Drop in an NSOutlineView
  • Index(es):
    • Date
    • Thread