• 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
resize text lines when nstextview is resized
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

resize text lines when nstextview is resized


  • Subject: resize text lines when nstextview is resized
  • From: Andrea Salomoni <email@hidden>
  • Date: Thu, 16 Feb 2006 23:30:52 +0100

Hi to all,

I'm looking for how to add programmatically a normal behavior i usually find in a IB NSTextView.
Assume that I have a long text line, and you start to resize your textview making it smaller.
While you resize the textview I would like to see the lines fit the textview and not disappear under the scrollview!


How can I do it programmatically?
I attach some code:

NSScrollView *scrollview = [[NSScrollView alloc]
            initWithFrame:cFrame];

NSSize contentSize = [scrollview contentSize];

NSSize newSize;
NSRect myRect;
NSSize mySize;
myRect = [scrollview bounds];
mySize = NSMakeSize(NSWidth(myRect), NSHeight(myRect));
newSize = [NSScrollView contentSizeForFrameSize:mySize
hasHorizontalScroller:NO hasVerticalScroller:YES borderType:NSNoBorder];
[scrollview setBorderType:NSNoBorder];
[scrollview setAutohidesScrollers:YES];
[scrollview setBorderType:NSBezelBorder];
[scrollview setHasVerticalScroller:YES];
[scrollview setHasHorizontalScroller:NO];
[scrollview setAutoresizingMask:NSViewWidthSizable |
NSViewHeightSizable];
[startTab setView:scrollview];
chatView = [[URLTextView alloc] initWithFrame:NSMakeRect (0,0,newSize.width,newSize.height)];


	[chatView setEditable:NO];
	[chatView setMinSize:NSMakeSize(0.0, contentSize.height)];
	[chatView setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
	[[chatView textContainer]
            setContainerSize:NSMakeSize(contentSize.width, FLT_MAX)];
	[[chatView textContainer] setWidthTracksTextView:YES];
	[chatView  setFrame:[scrollview frame]];
	[scrollview setDocumentView:chatView];

Thank you all
Andrea
_______________________________________________
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: resize text lines when nstextview is resized
      • From: Nik Youdale <email@hidden>
    • Re: resize text lines when nstextview is resized
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: Full screen applications and Apple UI elements
  • Next by Date: Re: why would anyone want to do that?
  • Previous by thread: Re: FMActivateFonts
  • Next by thread: Re: resize text lines when nstextview is resized
  • Index(es):
    • Date
    • Thread