NSTextList question
NSTextList question
- Subject: NSTextList question
- From: "Greg Wiseman" <email@hidden>
- Date: Mon, 5 Jun 2006 00:06:35 +0200
Hello,
I would like to use an NSTextList in an NSTextView but am having
trouble getting it to work. I have an NSString, which probably has
several linebreaks in it. I would like each line in the NSString to be
presented as an item in a list in my NSTextView.
Here is my code, which doesn't seem to work at all. Setting the font
attribute works, but the string doesn't appear as a list.
NSMutableAttributedString *attString = [[[NSMutableAttributedString
alloc] initWithString:plainOldNSString] autorelease];
[attString addAttribute:NSFontAttributeName value:[self methodFont]
range:NSMakeRange(0,[attString length])];
NSTextList *textList = [[[NSTextList alloc]
initWithMarkerFormat:@"{decimal}."
options:NSTextListPrependEnclosingMarker] autorelease];
NSMutableParagraphStyle *paragraphStyle = [[[NSMutableParagraphStyle
alloc] init] autorelease];
[paragraphStyle setTextLists:[NSArray arrayWithObject:textList]];
[attString addAttribute:NSParagraphStyleAttributeName
value:paragraphStyle range:NSMakeRange(0,[attString length])];
[[tvMethod textStorage] setAttributedString:attString];
where tvMethod is a pointer to my NSTextView.
I've searched the list archives, read the appropriate page on
cocoadev, and looked at all the results google gave me for the search
'nstextlist', to no avail. Can anybody tell me what I'm doing wrong?
And another question: in the event that the string is empty, if the
user begins typing in the textview, I would like them to immediately
be editing a new list. Any advice on the best way to implement this?
Thanks in advance,
Greg
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden