Re: Metrics for a NSTextField
Re: Metrics for a NSTextField
- Subject: Re: Metrics for a NSTextField
- From: Eric Gorr <email@hidden>
- Date: Thu, 26 Feb 2009 10:23:31 -0500
Hello Martin,
Martin Wierschin wrote:
> Eric Gorr Wrote:
> I'm not really familiar with the particulars of how the field
editor is
> configured, so take all this with a grain of salt...
>
> > The usedRect empty. I believe the reason why is because the
fieldEditor
> > that the window has given me has a zero width.
>
> Sizing the editor may not be the window's responsibility- it may
expect
> the control to do so. What happens if you resize the NSTextView and/
or
> NSTextContainer yourself as needed?
This is possible, but the documentation does not say anything about
this being necessary.
> In fact, you might have to call additional methods before it is
properly
> usable, eg: "setUpFieldEditorAttributes:"
Well, the documentation for setUpFieldEditorAttributes: says:
Sets up the field editor. You never invoke this method directly;
by
overriding it, however, you can customize the field editor.
I have no need to customize it...the default one it provides is just
fine.
> > If anyone has a suggestion on how to better accomplish this task,
I am
> > interested.
>
> What about just calling sizeToFit on your NSTextField and then
drawing
> the border around the full frame?
I was thinking the same thing and this would likely be just fine in my
specific case (and I am about to see if I can use sizeToFit to solve
my problem), but I am now just as interested in the general question
of how to correctly and generally get metric information for a
NSTextField.
Thanks again for your comments. They are useful.
If anyone is interested, I've posted a sample application
demonstrating the problem at:
http://ericgorr.net/cocoadev/label/TextFieldMetric.zip
It uses the drawRect: as described below.
If this is indeed a cocoa bug, I will report it.
If not and if anyone has any ideas on a reliable way to get metric
information for a NSTextField, please let me know.
_______________________________________________
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