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: 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