My revisions to DragAndDropOutlineEdit
My revisions to DragAndDropOutlineEdit
- Subject: My revisions to DragAndDropOutlineEdit
- From: George Orthwein <email@hidden>
- Date: Thu, 6 Jul 2006 16:00:05 -0400
So I went back to take another look at the tree controller/outline
view problems I had been putting off and... I *think* I might
actually have a working NSTreeController + Core Data +
NSOutlineView!!! (*knock on wood*)
http://home.comcast.net/~george.o/DragAndDropOutlineEdit.html
I started with Matt Holiday's DragAndDropOutlineEdit (http://
homepage.mac.com/matthol2/cocoa/page1/page1.html) and:
- added Count Key Path to avoid errors when dragging multiple items.
- added a "displayOrder" attribute to save ordering.
- added an "isExpanded" attribute to save/restore expansion states
even after Undo/Redo (mostly).
- added Undo action names.
- added some support for a max depth level.
- moved the outline code out of MyDocument and into
MyOutlineViewController so the project can be used as a template easier.
One little flaw though... I had to use a posing hack found on
cocoadev.com in order to solve certain errors I was getting on Undo:
http://www.cocoadev.com/index.pl?NSTreeControllerBugOrDeveloperError
(from "Frank" near the bottom)
The posing seems to work great (so thanks Frank!) but I'm a little
unsure to resort to such a thing. I'd be interested if anyone can
recommend a better workaround. Perhaps there is a particular
NSTreeController method to override? I'm probably grasping at straws
here, but I don't really want to get into writing a tree controller
from scratch (not sure I'd even know where to begin with that).
The easiest way I found to trigger the error was usually:
1) create a bunch of items with the New button
2) drag some (at least 3) to another to make them children
3) drag some (at least 2 but not all) of those children to another
top level item
4) Undo and then Redo
If you comment out the posing in windowControllerDidLoadNib, the
above will trigger an error.
So anyone who desires, please download and, ahem, try to break it.
And anyone who can find a better workaround than the class posing, or
has some other improvement, please share. I really think the
community needs a working OutlineView + ordered Core Data template to
fill the void until 10.5 comes along.
Thanks,
George
_______________________________________________
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