NSLayoutManager for NSTextField (was Re: Metrics for a NSTextField)
NSLayoutManager for NSTextField (was Re: Metrics for a NSTextField)
- Subject: NSLayoutManager for NSTextField (was Re: Metrics for a NSTextField)
- From: Eric Gorr <email@hidden>
- Date: Thu, 26 Feb 2009 12:21:01 -0500
Hello Michael,
On Feb 26, 2009, at 11:10 AM, Michael Ash wrote:
On Thu, Feb 26, 2009 at 10:49 AM, Eric Gorr <email@hidden>
wrote:
Unfortunately, sizeToFit does not work.
It doesn't appear one can constrain the width of a NSTextField and
only have
it's height adjustable. Basically, sizeToFit provides a size that
causes the
text in the field to fit on a single line.
Try sending -cellSizeForBounds: to your NSTextFieldCell. Give it a
bounds with the correct width but a very tall height, and it should
keep that width (or reduce it) and give you the appropriate height
with wrapping.
Thanks. I believe that will provide me some of the metric information
that I need, but not all of it.
For example, I also need to determine how many pixels 5 lines of text
are with a constrained width and there will be other metric
information for a NSTextField that I need as well.
What is clear is that a NSLayoutManager can answer every metric
question I have and NSLayoutManager seems to be the place where all of
the metric related methods have been placed.
What isn't clear how I can get a NSLayoutManager that will layout the
text in the same way as a NSTextField, but perhaps this isn't possible
because NSTextField does custom layout apart from a NSLayoutManager.
I thought I might be able to use a field editor, but as:
http://ericgorr.net/cocoadev/label/TextFieldMetric.zip
demonstrates, getting a field editor for a NSTextField isn't so easy
to obtain - of course, I may be doing some obviously (to someone else)
wrong.
I can't believe the questions I want to ask of the text system are
this difficult to obtain the answers to...
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden