• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Turning off Text Wrapping in NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
____________________________


  • Follow-Ups:
    • Re: Turning off Text Wrapping in NSTextView
      • From: Greg Titus <email@hidden>
  • Prev by Date: Unexpected behavior of NSNumberFormatter
  • Next by Date: Re: Unexpected behavior of NSNumberFormatter
  • Previous by thread: Re: Unexpected behavior of NSNumberFormatter
  • Next by thread: Re: Turning off Text Wrapping in NSTextView
  • Index(es):
    • Date
    • Thread