NSTextView line wrap toggle (was NSTextView exception with line wrap and horizontal scroller - RESOLVED)
NSTextView line wrap toggle (was NSTextView exception with line wrap and horizontal scroller - RESOLVED)
- Subject: NSTextView line wrap toggle (was NSTextView exception with line wrap and horizontal scroller - RESOLVED)
- From: "email@hidden" <email@hidden>
- Date: Thu, 3 Feb 2011 22:03:37 +0000
On 28 Jan 2011, at 21:34, email@hidden wrote:
> Does NSTextView officially support line wrapping with the horizontal scroller remaining visible?
> I have a placard in my scroller and don't want to remove it along with the scroller when I toggle between line wrapping and non wrapping.
>
>
Line wrapping with the horizontal scroller remaining visible is supported.
The exception I was experiencing was a result of misconfiguring the NSTextView - setHorizontallyResizable: for wrapped text.
The configuration below seems to work well but line wrapping does not seem to be precise with very large amounts of text (eg: log files > 2MB)
when the horizontal scrollbar will become active even when wrapping is enabled.
This effect may or may not be influenced by the state of NSLayoutManager - hasNonContiguousLayout.
- (void)setLineWrap:(BOOL)wrap
{
NSScrollView *textScrollView = [self enclosingScrollView];
NSSize contentSize = [textScrollView contentSize];
[self setMinSize:contentSize];
NSTextContainer *textContainer = [self textContainer];
if (wrap) {
[textScrollView setHasHorizontalScroller:YES];
[textContainer setContainerSize:NSMakeSize(contentSize.width, CGFLOAT_MAX)];
[textContainer setWidthTracksTextView: YES];
[self setHorizontallyResizable: NO];
} else {
[textScrollView setHasHorizontalScroller:YES];
[textContainer setContainerSize:NSMakeSize(CGFLOAT_MAX, CGFLOAT_MAX)];
[textContainer setWidthTracksTextView: NO];
[self setHorizontallyResizable: YES];
}
}
Regards
Jonathan Mitchell
Developer
Mugginsoft LLP
http://www.mugginsoft.com_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden