• 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: Mon, 11 Oct 2004 13:21:51 -0700

After poking around in www.cocoabuilder.com some more, I found this method
-sizeToFit, which makes things much easier, so this is a slam-dunk for
NSTextField. Contrary to statements in the archives, this works for
vertical as well as horizontal. No need for NSTextView. Here's the answer:

- (void)resizeTextField:(NSTextField*)textField
forSuperview:(NSScrollView*)superview
// In Interface Builder, checkbox these attributes of superview:
// Show Vertical Scroller
// Show Horizontal Scroller
// Automatically Hide Scrollers
// Then, if the text is small enough to fit, textField will be sized
// to fill the scroll view, and there will be no scrollers. But if the
// text is to big for the scroll view, scroller(s) will appear.
{
[textField sizeToFit] ;
NSRect theFrame = [textField frame] ;
NSSize superSize = [superview contentSize] ;
float superHeight = superSize.height ;
float superWidth = superSize.width ;
theFrame.size.height = MAX(theFrame.size.height, superHeight) ;
theFrame.size.width = MAX(theFrame.size.width, superWidth ) ;
[textField setFrame:theFrame] ;
}



_______________________________________________
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

References: 
 >Re: NSTextField or NSTextView for this job? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: [NEWBIE] How to localize toolbar button?
  • Next by Date: WebView Content from String?
  • Previous by thread: Re: NSTextField or NSTextView for this job?
  • Next by thread: Find the 'Application Support' folder
  • Index(es):
    • Date
    • Thread