Re: NSTreeController drag and drop
Re: NSTreeController drag and drop
- Subject: Re: NSTreeController drag and drop
- From: Keith Blount <email@hidden>
- Date: Tue, 26 Jul 2005 15:15:48 -0700 (PDT)
Thanks for the reply, Mike, much appreciated. I've
been using Scott's tips throughout, but in the final
analysis I found no way of getting drag and drop to
work without strange behaviour. It would seem to work
but then break in certain situations after a lot of
testing. Manipulating the data directly only seemed to
confused the tree controller, no matter what I did. I
eventually took a step back and realised that in order
to support drag and drop and expandable state saving
(because it's impossible to get
-outlineView:itemForPersistentObject: working with
NSTreeController), I had written more code hacking
around NSTreeController than I would have just by
implementing the datasource methods. So I have
returned to using a non-bindings outline view without
NSTreeController, and now everything works fine and,
ironically, I have less code.
I think NSTreeController is a great start, but I think
it has a little way to go before it is really useful
for projects that want anything more than a very basic
outline view. I hope Apple do some more work on it - I
have filed a couple of enhancement requests in that
hope.
Thanks again and all the best,
Keith
--- Michael McCracken <email@hidden>
wrote:
> 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/
>
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
_______________________________________________
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