How to compute optimal NSField size?
How to compute optimal NSField size?
- Subject: How to compute optimal NSField size?
- From: Leon Starr <email@hidden>
- Date: Sun, 17 Jun 2007 12:47:29 -0700
I am creating editable NSFields programmatically on a canvas for a
kind of UML draw
tool.
I am trying to figure out how to set the frame size of a field based
on the quantity of entered
text. Let's say the field can store a maximum of 40 characters, but
typically holds only 10-15
characters. If there is a small amount of text, I would like the
field frame to be the "small size".
But if the user enters 30 chars, I would like to resize the field
frame to the "big size".
The trick is that I want to take the selected font and type size into
account so that I never
end up clipping text when it is under 40 characters. At the same
time, I don't want to keep
a field frame unnecessarily large if it contains only 10-15 chars.
So the "big size" and "small
size" must be re-computed when the font and type size is selected.
Fortunately, once
selected, the size/font will be the same for the entire canvas.
Has anyone done this before? I am looking for hints as to any
classes/methods I can
use to get the data I need to perform the computation. I am also
wondering if I can dynamically
resize an NSField frame or if I need to copy/replace it instead.
I hate open ended questions, and I realize this is one of them, but
any help, code examples, etc.
would be greatly appreciated. And, yes, I am reading/re-reading all
of the text/font/field docs in
the ADC library. I guess what I need to know is in there somewhere,
but maybe someone
can help me refine my search!
- Leon Starr
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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