• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Metrics for a NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Metrics for a NSTextField


  • Subject: Re: Metrics for a NSTextField
  • From: Eric Gorr <email@hidden>
  • Date: Thu, 26 Feb 2009 10:49:07 -0500


On Feb 26, 2009, at 10:23 AM, Eric Gorr wrote:

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.

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.

Furthermore, it is unclear how one would provide a custom calcSize or calcDrawInfo: method to do the right thing.


_______________________________________________

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


  • Follow-Ups:
    • Re: Metrics for a NSTextField
      • From: Martin Wierschin <email@hidden>
    • Re: Metrics for a NSTextField
      • From: Michael Ash <email@hidden>
References: 
 >Metrics for a NSTextField (From: Eric Gorr <email@hidden>)
 >Re: Metrics for a NSTextField (From: Eric Gorr <email@hidden>)
 >Re: Metrics for a NSTextField (From: Eric Gorr <email@hidden>)

  • Prev by Date: Re: renaming a file with special/reserved characters in name
  • Next by Date: Re: One IBAction, multiple results from multiple methods
  • Previous by thread: Re: Metrics for a NSTextField
  • Next by thread: Re: Metrics for a NSTextField
  • Index(es):
    • Date
    • Thread