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