Re: NSTextContainer subclass question
Re: NSTextContainer subclass question
- Subject: Re: NSTextContainer subclass question
- From: Douglas Davidson <email@hidden>
- Date: Wed, 27 Nov 2002 11:04:09 -0800
On Wednesday, November 27, 2002, at 10:40 AM, Brock Brandenberg wrote:
In a quick sample project, I have a subclass of NSTextContainer that
overrides the lineFragmentRectForProposedRect: method, returning
appropriate
rects for a custom shape. In an NSApplication delegate, I'm simply
replacing
the default NSTextContainer for a NSTextView that is instantiated from
a nib
with my subclass. When text is entered into the NSTextView and the
shape
will no longer hold all of the text, the subclass method will return a
NSZeroRect. In this case, the NSTextView no longer draws the text. As
long
as the text is short enough to fit the shape, however, it draws.
Is it a requirement that an NSLayoutManager has enough text containers
to
hold all the text before drawing occurs? In my example, I'm hacking
the sole
NSTextContainer for a NSTextView, so I assume that I'm breaking its
usual
operation in some way. However, I would assume that there is some way
to
catch the end of layout for this sole container and at least tell the
NSTextView to draw what it can to make this sample work. I'm familiar
with
the NSLayoutManager delegate methods, so in my particular application,
I can
insure that extra containers are added to hold the text. However, I'd
like
to avoid having to do so and would rather ignore any overflowed text.
The
docs are pretty thin around NSTextContainer subclasses and their
interaction
with the rest of the text system, so any assistance with handling text
container overflow would be helpful.
It should not be necessary for there to be sufficient containers to
hold all of the text. Yes, you can use the layout manager delegate
methods (as TextEdit does) to add additional text containers if those
present are full, but there is no requirement that you do so. However,
it's possible that there's a bug here for which adding an additional
large undisplayed text container would be a workaround. Let me ask--is
the text you are drawing all one paragraph? Does inserting explicit
line breaks into the text change the result?
Douglas Davidson
_______________________________________________
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.