# Line Wrap for Textarea in Xojo Mac applications with MBS Plugins

**URL:** <https://forum.xojo.com/t/line-wrap-for-textarea-in-xojo-mac-applications-with-mbs-plugins/44844>\
**Category:** Extras\
**Created:** [August 16, 2018, 9:11am UTC](https://forum.xojo.com/t/line-wrap-for-textarea-in-xojo-mac-applications-with-mbs-plugins/44844 "2018-08-16T09:11:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [August 16, 2018, 9:11am UTC](https://forum.xojo.com/t/line-wrap-for-textarea-in-xojo-mac-applications-with-mbs-plugins/44844/1 "2018-08-16T09:11:38Z")

</div>

Today we have a method for you to turn on/off line wrapping in a Textarea control in a Xojo Mac application by using [NSTextContainerMBS](http://www.monkeybreadsoftware.net/class-nstextcontainermbs.shtml) and [NSScrollViewMBS](http://www.monkeybreadsoftware.net/class-nsscrollviewmbs.shtml) classes with [NSTextViewMBS](http://www.monkeybreadsoftware.net/class-nstextviewmbs.shtml) class in our [MBS Xojo MacCocoa Plugin](http://www.monkeybreadsoftware.de/xojo/plugin-maccocoa.shtml):

[code]Sub SetLineWrap(TextView as NSTextViewMBS, isWrap as Boolean)  
dim cLargeNum as Double = 10000000

```
dim myScrollView as NSScrollViewMBS = TextView.enclosingScrollView
dim myTextContainer as NSTextContainerMBS = TextView.textContainer

if not isWrap then
	
	myScrollView.hasHorizontalScroller = True
	myScrollView.autoresizingMask = TextView.NSViewHeightSizable+TextView.NSViewWidthSizable
	
	myTextContainer.containerSize = NSMakeSizeMBS(cLargeNum, cLargeNum)
	myTextContainer.widthTracksTextView = false
	
	TextView.setMaxSize(cLargeNum, cLargeNum)
	TextView.isHorizontallyResizable = True
	TextView.autoresizingMask = TextView.NSViewNotSizable
	
else
	
	myScrollView.hasHorizontalScroller = False
	myScrollView.autoresizingMask = 0
	
	myTextContainer.containerSize = NSMakeSizeMBS(myTextContainer.containerSize.Width, cLargeNum)
	myTextContainer.widthTracksTextView = True
	
	TextView.setMaxSize(TextView.visibleRect.Width, cLargeNum)
	TextView.isHorizontallyResizable = false
	TextView.autoresizingMask = TextView.NSViewHeightSizable+TextView.NSViewWidthSizable
	
end if

TextView.needsDisplay = True

```

End Sub[/code]

As you see the main difference between both modes is whether the text content view resizes with the the textarea control. Normally it does, but to disable line wrap, we disable that and allow it to size to a huge size horizontally.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 7:19pm UTC](https://forum.xojo.com/t/line-wrap-for-textarea-in-xojo-mac-applications-with-mbs-plugins/44844/2 "2020-10-29T19:19:44Z")

</div>


