• 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: NSTextField or NSTextView for this job?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSTextField or NSTextView for this job?
      • From: Jerry Krinock <email@hidden>
References: 
 >Re: NSTextField or NSTextView for this job? (From: Brent Stace <email@hidden>)

  • Prev by Date: Re: Getting a question answered
  • Next by Date: Re: Getting a question answered
  • Previous by thread: Re: NSTextField or NSTextView for this job?
  • Next by thread: Re: NSTextField or NSTextView for this job?
  • Index(es):
    • Date
    • Thread