• 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
NSTextView line wrap toggle (was NSTextView exception with line wrap and horizontal scroller - RESOLVED)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: Re: Home-brewed code is 100X faster than -[NSScanner scanDecimal:] ??
  • Next by Date: Re: NSBitmapImageRep with floating point values
  • Previous by thread: RE: NSBitmapImageRep with floating point values
  • Next by thread: Disable Links in WebView?
  • Index(es):
    • Date
    • Thread