Re: NSTextField or NSTextView for this job?
Re: NSTextField or NSTextView for this job?
- Subject: Re: NSTextField or NSTextView for this job?
- From: Jerry Krinock <email@hidden>
- Date: Sat, 09 Oct 2004 21:16:02 -0700
on 04/10/09 17:35, Brent Stace at email@hidden wrote:
>
button = [[NSButton allocWithZone:zone ]
>
initWithFrame:NSMakeRect(1.0,originY,[[NSFont
>
messageFontOfSize:-1.0] widthOfString:s] + 30.0
>
,BUTTON_HEIGHT)];
Thanks, Brent. I never would have thunk of looking in NSFont. The
following code which I extracted from yours seems to do it:
NSFont* systemFont = [NSFont messageFontOfSize:-1.0] ;
// 0.0 or neg number returns system font
textHeight = [systemFont defaultLineHeightForFont]*nLines ;
textWidth = [systemFont widthOfString:myText] ;
except that the text width is the total width of all the lines in the
string; it ignores newlines. Arggghh!!! Oh well, since I've invested an
hour or so in it now, I guess I'll *just* make an array of strings by
splitting myString at the newlines, measuring each one, and finding the max.
But that's for tomorrow...
_______________________________________________
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