• 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
NSTreeController drag and drop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTreeController drag and drop


  • Subject: NSTreeController drag and drop
  • From: Keith Blount <email@hidden>
  • Date: Tue, 26 Jul 2005 05:25:02 -0700 (PDT)

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

  • Follow-Ups:
    • Re: NSTreeController drag and drop
      • From: Michael McCracken <email@hidden>
  • Prev by Date: Re: NSMutableCopy Issue - New to Cocoa and Objective-C
  • Next by Date: Re: NSMutableCopy Issue - New to Cocoa and Objective-C
  • Previous by thread: Re: other question ...
  • Next by thread: Re: NSTreeController drag and drop
  • Index(es):
    • Date
    • Thread