On 28 Jan 2011, at 21:34, [email protected] 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 protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]