Re: NSTreeController drag and drop
Re: NSTreeController drag and drop
- Subject: Re: NSTreeController drag and drop
- From: Michael McCracken <email@hidden>
- Date: Tue, 26 Jul 2005 14:44:03 -0700
Keith, Scott Stevenson has some tips about this here:
http://theocacao.com/document.page/130 , but it sounds like you've
already gotten that far.
I don't really think there's anything wrong with just manipulating the
content directly, especially if that works and the code makes sense. I
have had to do the same thing with NSTreeController, and as far as I
can see it's really just a small step back towards pre-bindings cocoa,
which wasn't all that bad.
Although if anyone does have some insight about if you should always
use the controllers' methods for manipulating content, and how to do
it right, I'd be glad to hear it too.
-mike
On 7/26/05, Keith Blount <email@hidden> wrote:
> Hello,
>
> I am just wondering if anyone has had any success
> implementing drag and drop with NSTreeController. I
> have got it working fine for my app, but I want to
> check that the way I am doing it is okay. It is the
> -outlineView:acceptDrop:item:childIndexes: method that
> I am unsure about. It seems to me that I should be
> using NSTreeController's
> -insertObject:atArrangedIndexPath: and
> -removeObjectAtArrangedIndexPath: methods to complete
> my drop, but I have had less-than-reliable results
> with these. For a start, I have found that
> -insertObject:atArrangedIndexPath: behaves erratically
> when dropping on the root (ie. when the targetItem
> passed in is NULL). It also seems impossible to use
> -removeObjectAtArrangedIndexPath: to remove objects
> that have been dragged (when the source and
> destination are the same), because we need the index
> paths of all of the dragged items. This is complicated
> because: 1) These index paths may have changed after
> inserting the dropped items; 2) NSTreeController only
> provides methods for getting the index paths of
> selected objects - I can't see any way to calculate
> the index paths from an array of dragged items.
>
> The only solution I have come up with is to manipulate
> the content arrays directly, without using any of
> NSTreeController's methods, and then ensuring that the
> outline view remains up to date using
> -reloadItem:reloadChildren: and -reloadData (if I
> don't do this every time I add a new item, I get some
> very screwy results, which is only a problem when
> using NSTreeController).
>
> Like I say, I have drag and drop working, but I feel
> that I may be doing it the wrong way because I am not
> using my tree controller to manage the drop. If anyone
> has any examples of an
> -outlineView:acceptDrop:item:childIndexes: method that
> does this in a better way (using NSTreeController
> methods), or any comments in general about this
> process, I would be very grateful.
>
> Many thanks,
> Keith
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
--
Michael McCracken
UCSD CSE PhD Candidate
research: http://www.cse.ucsd.edu/~mmccrack/
misc: http://michael-mccracken.net/blog/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden