Re: Text architecture question
Re: Text architecture question
- Subject: Re: Text architecture question
- From: Douglas Davidson <email@hidden>
- Date: Mon, 25 Oct 2004 12:02:47 -0700
On Oct 22, 2004, at 9:30 PM, Erik Hanson wrote:
Briefly, the window will display text much like the comments are
displayed on Slashdot. That is, the window contains many (100+) chunks
of text, each of which may be a different length. The chunks will be
nested in a hierarchy. I'd also like to put in a disclosure triangle
control to show and hide a chunk's children.
My initial implementation used one NSTextView for each chunk. But the
performance of all of those NSTextViews was pretty bad (resizing a
window with 100 NSTextViews was noticeably slow). I've read that cells
are faster than views, but I haven't figured cells out completely yet.
My next thought was to use one NSText view and use paragraph styles to
control the indenting, but I haven't been able to figure out how to
embed a control (the disclosure triangle button) in the view.
I had also thought about using an NSOutlineView, but it won't allow
cells of varying heights. I found a third-party outline view with
resizable rows [1], so I might be able to use that. I was sort of
hoping to have the disclosure triangle indented along with the rest of
the text, but I can probably live without this.
There are several ways you could do this. The obvious one is along the
lines of NSOutlineView, i.e. a single view drawing the individual
portions of text either using cells or using string drawing, and adding
a field editor as needed for editing text in a single portion.
Alternatively, you could use a single NSTextView subclass, as you
suggest, using paragraph styles to control the indenting. Depending on
your intent for editing, you could use the various text view delegate
methods to control editing and/or selection of particular portions of
the text. Controls can't be embedded directly in a text view, but you
can include images via NSTextAttachment, and a custom
NSTextAttachmentCell subclass can respond to mouse events; that would
probably enable you to do what you want to do with this without too
much difficulty.
Douglas Davidson
_______________________________________________
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