Example: /MacControls/NSTextView Unlimited Tab

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/MacControls/NSTextView Unlimited Tab


Required plugins for this example: MBS MacBase Plugin, MBS MacCocoa Plugin, MBS Main Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/NSTextView Unlimited Tab

This example is the version from Sat, 28th Dec 2012.

Project "NSTextView Unlimited Tab.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control TextArea1 Inherits TextArea
ControlInstance TextArea1 Inherits TextArea
EventHandler Sub Open() dim l as new NSLayoutManagerMBS dim n as NSTextViewMBS = TextArea1.NSTextViewMBS dim c as NSTextContainerMBS = n.textContainer c.replaceLayoutManager l l.textColor = NSColorMBS.redColor l.showInvisibleCharacters = True End EventHandler
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control TextArea2 Inherits TextArea
ControlInstance TextArea2 Inherits TextArea
EventHandler Sub Open() dim l as new NSLayoutManagerMBS dim n as NSTextViewMBS = TextArea2.NSTextViewMBS dim c as NSTextContainerMBS = n.textContainer c.replaceLayoutManager l l.textColor = NSColorMBS.redColor l.showInvisibleCharacters = True // Do not wrap with a tabstop. setUnlimitedTab(n) End EventHandler
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Sub setUnlimitedTab(t as NSTextViewMBS) // NSTextView wraps the lines in the 12th tabstop even though there is space enough to hold the whole line. // This method does not make the lines wrap unexpectedly. dim IsUseNSParagraphStyleDefault as boolean ' Get defaultParagraphStyle dim n as NSParagraphStyleMBS = t.defaultParagraphStyle if n is nil then n = NSParagraphStyleMBS.defaultParagraphStyle IsUseNSParagraphStyleDefault = true end if dim m as NSMutableParagraphStyleMBS = n.mutableCopy ' NSParagraphStyleMBS.defaultParagraphStyle.lineHeightMultiple is 0.0 if IsUseNSParagraphStyleDefault then m.setLineHeightMultiple( 1.0 ) end if ' Set tab Interval (28 is default) m.setDefaultTabInterval( 28.0 ) ' Set empty array to tabStops dim tabs() as NSTextTabMBS m.setTabStops( tabs ) ' Set NSMutableParagraphStyle to defaultParagraphStyle of NSTextView t.defaultParagraphStyle = m ' Set NSDictionary to typingAttributes of NSTextView dim d as new Dictionary d.Value( t.layoutManager.attributedString.NSParagraphStyleAttributeName ) = m t.typingAttributes = d ' Set attributes to the line which has already existed t.textStorage.addAttributes( d, NSMakeRangeMBS(0, t.textStorage.length) ) End Sub
Note "Note"
This example was created by Kuniaki Maruyama
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

See also:

The items on this page are in the following plugins: MBS MacControls Plugin.


💬 Ask a question or report a problem