Re: resize text lines when nstextview is resized
Re: resize text lines when nstextview is resized
- Subject: Re: resize text lines when nstextview is resized
- From: Nik Youdale <email@hidden>
- Date: Fri, 17 Feb 2006 17:43:19 +1100
Hi,
Do you mean text wrapping?
I beleive if you set the textContainer width to be the same width as
the actual textView, the text should wrap automatically when the
textview is resized.
- Nik
On 17/02/2006, at 9:30 AM, Andrea Salomoni wrote:
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:
40gmail.com
This email sent to email@hidden
_______________________________________________
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