Re: Preferred hight of NSTextField
Re: Preferred hight of NSTextField
- Subject: Re: Preferred hight of NSTextField
- From: Greg Herlihy <email@hidden>
- Date: Thu, 02 Feb 2006 13:09:57 -0800
- Thread-topic: Preferred hight of NSTextField
Calling [myField sizeToFit] is another way to ensure that the the text field
has adequate height.
Greg
On 2/2/06 10:53 AM, "Kaspar Mösinger" <email@hidden> wrote:
>
> 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
_______________________________________________
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