NSOutlineView expanded state persistence
NSOutlineView expanded state persistence
- Subject: NSOutlineView expanded state persistence
- From: Michael McCracken <email@hidden>
- Date: Mon, 26 Jan 2004 14:27:20 -0800
Hi, this question has caused me problems on and off for literally
years, and it's time to get it straight in my head. I think I'm just
being dumb, so bear with me...
How do I refresh the data source for an NSOutlineView and keep the
expanded/collapsed state?
Here's one example: I have a routine that scans the text in an
NSTextView on a timer, and builds a tree out of lines that start with
\section or \subsection.
At the moment, it's represented as nested NSMutableArrays. ( a detail,
the 0th element in each array is a dictionary that has the text of the
line to use as the objectvalue in the outline view)
Every time the contents are re-scanned, the root array is emptied and
the tree is rebuilt with new objects, which end up being equivalent to
the old objects in the old tree up to the point just beyond an edit
(because the text range is stored in the aforementioned dictionary).
I don't implement persistentobjectforitem or its counterpart. (because
I don't understand what they do and all online references to them just
confused me)
*What happens: on a refresh (triggered by an edit in the text view) the
outline view stays the same except that the item nearest to the edit is
collapsed, all the way up to its parent, and so is everything after it.
*What I want: the outline should only change if the structure changed
(ie, if the number of lines that had \section, etc changed or their
titles changed) and I don't want anything to collapse without user
intervention.
Is the representation as arrays a bad idea?
How does NSOutlineView handle changes in the datasource with respect to
expanded/collapsed status?
What does persistentobjectforitem actually do for me?
Thanks,
-mike
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.