View Full Version : NSTextList - need help
rethish
Dec 19, 2008, 12:26 AM
hi all,
I would like to use bullets and numberings in the textview .
I found some of search results for this topic ,they were about NSTextList .
How can it be used.
please provide me some help on NSTextList.
thank you
kainjow
Dec 19, 2008, 11:40 AM
Have you looked at the documentation? It describes how to use it.
rethish
Dec 23, 2008, 01:12 AM
hai,
I had referred the documentation. I managed to understand a little concepts by referring some examples from websites. Now the task is partially done .
But the problem now is , this bullets and numberings works only if there is no contents(text) in the textview.
i want to use bullets and numberings to text that is already been typed , likewise in textedit
the code is :
if([[popupbutton titleOfSelectedItem] isEqualToString:@"-" ])
{
NSTextStorage *storage=[textview textStorage];
[storage beginEditing];
NSMutableAttributedString *text = [[NSMutableAttributedString
alloc]initWithAttributedString:storage];
NSMutableParagraphStyle *mps = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
NSTextList *listItem = [[NSTextList alloc] initWithMarkerFormat:@"{hyphen}" options:NSTextListPrependEnclosingMarker];
[mps setTextLists:[NSArray arrayWithObject:listItem]];
NSMutableString *tabs = [@"\t" mutableCopy];
[tabs appendString:@"\t"];
[text appendAttributedString: [[NSAttributedString alloc]
initWithString:[NSString stringWithFormat:@"\t%@\t", [listItem markerForItemNumber:1] ]
attributes:[NSDictionary dictionaryWithObject:mps
forKey:NSParagraphStyleAttributeName]]];
[storage setAttributedString:text];
[storage endEditing];
}
please provide me some tips to overcome this problem
thankyou.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.