« New MacBook Pro teste… | Home | MBS Xojo Plugins, ver… »

Line Wrap for Textarea in Xojo Mac applications

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:

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
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. The biggest plugin in space...
16 08 18 - 10:42