Re: NSTextView without word wrap
Re: NSTextView without word wrap
- Subject: Re: NSTextView without word wrap
- From: Mark Wright <email@hidden>
- Date: Wed, 16 Oct 2013 13:33:19 +0100
Shouldn't that be:
- (BOOL) wrapsLines {
return ![self isHorizontallyResizable];
}
Otherwise if you set it to YES the getter will return NO because of the [self setHorizontallyResizable: !wraps] line in the setter?
On 16 Oct 2013, at 06:55, Jens Alfke wrote:
>
> On Oct 12, 2013, at 2:42 PM, Mikael Hakman <email@hidden> wrote:
>
>> How can I make NSTextView not to do word wrap? Thanks.
>
> Basically you have to make the view’s text container infinitely wide. Here’s an implementation of a .wrapsLines property that I used in a subclass of NSTextView a few years ago.
>
> - (BOOL) wrapsLines {
> return [self isHorizontallyResizable];
> }
>
> - (void) setWrapsLines: (BOOL)wraps {
> [self setHorizontallyResizable: !wraps];
> NSSize containerSize = self.textContainer.containerSize;
> containerSize.width = wraps ?self.enclosingScrollView.documentVisibleRect.size.width :FLT_MAX;
> [[self textContainer] setContainerSize: containerSize];
> [[self textContainer] setWidthTracksTextView: wraps];
> [[self enclosingScrollView] setHasHorizontalScroller: !wraps];
> [self setNeedsDisplay: YES];
> }
>
> —Jens
> _______________________________________________
>
> 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
_______________________________________________
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