Line Wrap for Textarea in Xojo Mac applications with MBS Plugins

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 and NSScrollViewMBS classes with NSTextViewMBS class in our MBS Xojo MacCocoa Plugin:

[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
	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.