Turning off Text Wrapping in NSTextView
Turning off Text Wrapping in NSTextView
- Subject: Turning off Text Wrapping in NSTextView
- From: Max Cantor• <email@hidden>
- Date: Thu, 27 Dec 2001 16:00:26 -0500
Hello,
I'm working on a project which requires an NSTextView to display
text which doesn't wrap and simply scrolls horizontally in addition to
vertically. However, as much as I try, NSTextView refuses to do this,
it either wraps the text or clips it, leaving some to the right
invisible, but wont scroll to the right (the scroll bar is greyed out as
if all text were visible). I have tried every combination of the
following lines of code:
I use the following code to configure the NSTextView:
[resultTextScrollView setHasHorizontalScroller:YES];
[resultTextView setHorizontallyResizable:YES];
[resultTextView
setAutoresizingMask:(NSViewWidthSizable|NSViewHeightSizable)];
[[resultTextView textContainer]
setContainerSize:NSMakeSize(1000000.0,1000000.0)];
[[resultTextView textContainer] setWidthTracksTextView:NO];
And the following code to apply a paragraph style to the string in
the NSTextView:
[[resultTextView textStorage] beginEditing];
[resultTextView setString:[stringUtils
stdStringFromResultSet:rsTemp]];
paragraphStyle = [[NSParagraphStyle defaultParagraphStyle]
mutableCopy];
[paragraphStyle setLineBreakMode:NSLineBreakByClipping];
[[resultTextView textStorage] addAttribute:@"NSParagraphStyle"
value:paragraphStyle
range:NSMakeRange(0,[[resultTextView string] length])];
[[resultTextView textStorage] endEditing];
[resultTextView sizeToFit];
[resultTextView setNeedsDisplay:YES];
thank you in advance,
____________________________
Max Cantor
Apple Campus Rep -
University of Pennsylvania
(215)287-5507
email@hidden
____________________________