Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/Text List
Function:
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/Text List
This example is the version from Wed, 13th Feb 2018.
Project "Text List.rbp"
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 tab as string = encodings.UTF8.chr(9) dim tv as NSTextViewMBS = me.NSTextViewMBS dim ts as NSTextStorageMBS = tv.textStorage dim items() as string = array("One", "Two", "Three", "Four") // build our four demo text lists dim tl1 as new NSTextListMBS("{disc}") dim tl2 as new NSTextListMBS("{decimal}") dim tl3 as new NSTextListMBS("{upper-roman}") dim tl4 as new NSTextListMBS("{diamond}") tl1.startingItemNumber = 1 tl2.startingItemNumber = 1 tl3.startingItemNumber = 1 tl4.startingItemNumber = 1 // make editible Paragraph styles dim ps1 as NSMutableParagraphStyleMBS = NSParagraphStyleMBS.defaultParagraphStyle.mutableCopy dim ps2 as NSMutableParagraphStyleMBS = NSParagraphStyleMBS.defaultParagraphStyle.mutableCopy dim ps3 as NSMutableParagraphStyleMBS = NSParagraphStyleMBS.defaultParagraphStyle.mutableCopy dim ps4 as NSMutableParagraphStyleMBS = NSParagraphStyleMBS.defaultParagraphStyle.mutableCopy // assign our text lists ps1.setTextLists array(tl1) ps2.setTextLists array(tl2) ps3.setTextLists array(tl3) ps4.setTextLists array(tl4) // add paragraph styles 'ts.addAttribute ts.NSParagraphStyleAttributeName, ps1, r1 'ts.addAttribute ts.NSParagraphStyleAttributeName, ps2, r2 'ts.addAttribute ts.NSParagraphStyleAttributeName, ps3, r3 'ts.addAttribute ts.NSParagraphStyleAttributeName, ps4, r4 ts.appendString "Normal Dots" ts.appendString EndOfLine ts.appendString EndOfLine dim n as integer = 1 tl1.startingItemNumber = n for each it as string in items dim a as new NSMutableAttributedStringMBS call a.initWithString(tab+tl1.markerForItemNumber(n)+tab+it+EndOfLine) a.addAttribute a.NSParagraphStyleAttributeName, ps1, a.Range n = n + 1 ts.appendAttributedString a next ts.appendString EndOfLine ts.appendString "Arabic Numbers" ts.appendString EndOfLine ts.appendString EndOfLine tl2.startingItemNumber = n for each it as string in items dim a as new NSMutableAttributedStringMBS call a.initWithString(tab+tl2.markerForItemNumber(n)+tab+it+EndOfLine) a.addAttribute a.NSParagraphStyleAttributeName, ps2, a.Range n = n + 1 ts.appendAttributedString a next ts.appendString EndOfLine ts.appendString "Roman Numbers" ts.appendString EndOfLine ts.appendString EndOfLine tl3.startingItemNumber = n for each it as string in items dim a as new NSMutableAttributedStringMBS call a.initWithString(tab+tl3.markerForItemNumber(n)+tab+it+EndOfLine) a.addAttribute a.NSParagraphStyleAttributeName, ps3, a.Range n = n + 1 ts.appendAttributedString a next ts.appendString EndOfLine ts.appendString "Diamond Dots" ts.appendString EndOfLine ts.appendString EndOfLine tl4.startingItemNumber = n for each it as string in items dim a as new NSMutableAttributedStringMBS call a.initWithString(tab+tl4.markerForItemNumber(n)+tab+it+EndOfLine) a.addAttribute a.NSParagraphStyleAttributeName, ps4, a.Range n = n + 1 ts.appendAttributedString a next 'Break // inspect in debugger End EventHandler
End Control
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

See also:

Feedback, Comments & Corrections

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





Links
MBS Xojo Plugins