• 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: Preferred hight of NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Preferred hight of NSTextField


  • Subject: Re: Preferred hight of NSTextField
  • From: Kaspar Mösinger <email@hidden>
  • Date: Thu, 2 Feb 2006 19:53:15 +0100


On 02.02.2006, at 18:55, Joshua Scott Emmons wrote:

Is there a way to get the preferred hight of a NSTextField? I want to resize a window, so that the non-editable textfield has enough space to display all its lines.

To make sure my text field is tall enough to contain all its text when I draw it, I use the following:


NSRect frame = [myField frame];
frame.size.height = FLT_MAX;
frame.size.height = [[myField cell] cellSizeForBounds:frame].height;
[myField setFrame:frame];

This also has the quirk of never setting a height less than that needed to display a single line of text. That may be what you want, or it may not.


Cheers, -Joshua Emmons



This is exactly, what I've been searching for!

Thank you!
Kaspar
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Preferred hight of NSTextField
      • From: Greg Herlihy <email@hidden>
References: 
 >Preferred hight of NSTextField (From: Kaspar Mösinger <email@hidden>)

  • Prev by Date: Re: Converting error codes to readable strings?
  • Next by Date: Re: converting/reading input argument as utf8
  • Previous by thread: Binding NSPopupButton to a set of NSObjects
  • Next by thread: Re: Preferred hight of NSTextField
  • Index(es):
    • Date
    • Thread