Re: Sync NSOutlineView and NSTextView for outliner
Re: Sync NSOutlineView and NSTextView for outliner
- Subject: Re: Sync NSOutlineView and NSTextView for outliner
- From: Todd Ransom <email@hidden>
- Date: Sun, 17 Jul 2005 09:37:25 -0600
I have recently tackled the same problem and here is what I came up
with.
The items in your outline view are instances of some custom class.
Add an instance variable of type NSTextStorage to your custom class
along with appropriate accessors. Whenever the selection on your
outline view changes, swap the text storage of the text view using
[[textView layoutManager] replaceTextStorage:]
I also looked at using the text itself as the main storage and tying
it to the outline items via custom attributes. It seemed much easier
to me to compose the text from properties of the outline items than
to try and decompose the text into a bunch of outline items.
Let me know if you need more detail.
Todd Ransom
Return Self Software
http://returnself.com
On Jul 17, 2005, at 4:48 AM, Keith Blount wrote:
Hello,
I am hoping somebody might have some conceptual advice
on how to approach the following problem:
As part of the app I'm working on, I would like to
include an outliner like the one in Mellel or like
Jer's Novel Writer. The set-up would be like this:
There would be an outline view on the left and a text
view on the right. Whenever an item is added to the
outline view, a new text section is simultaneously
added to the text view. (This part is straightforward,
as I can just inset the text at the same time as
inserting the item in the outline view.)
Thus, each item in the outline view should represent a
block of text in the text view. Whenever an item is
moved around (eg. through drag'n'drop) in the outline
view, it should also be moved around in the text view.
And vice versa - if the user cuts and pastes a section
to a different place in the text view, the outline
view should reflect that.
At the moment I'm at a bit of a loss as to the best
way to approach this. I am thinking that whenever the
user adds an item to the outline view, I could add
some text with the same title as the item into the
text view, with a custom attribute set to that text
referencing the item in the outline view, but there
are still a lot of conceptual problems here - for
instance, tracking what level an item should be at
when moved around in the text view.
If anyone has any suggestions at all, I would be very
grateful.
Many thanks,
Keith
____________________________________________________
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
_______________________________________________
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