resize text lines when nstextview is resized
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