Platforms to show: All Mac Windows Linux Cross-Platform
/MacControls/Line wrap in TextArea
Required plugins for this example: MBS MacCocoa Plugin, MBS MacBase Plugin, MBS Main Plugin, MBS MacControls Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/Line wrap in TextArea
This example is the version from Fri, 16th Aug 2018.
Project "Line wrap in TextArea.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control TextArea1 Inherits TextArea
ControlInstance TextArea1 Inherits TextArea
End Control
Control CheckBox1 Inherits CheckBox
ControlInstance CheckBox1 Inherits CheckBox
EventHandler Sub Action()
SetLineWrap(TextArea1.NSTextViewMBS, me.Value)
End EventHandler
End Control
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
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project
The items on this page are in the following plugins: MBS MacControls Plugin.