Adding attributes to text in a text table cell
Adding attributes to text in a text table cell
- Subject: Adding attributes to text in a text table cell
- From: Charles Jenkins <email@hidden>
- Date: Thu, 20 Nov 2014 16:47:43 -0500
I have an NSTextTable in which each cell will contain the entire text of a small RTF document. I want the user to be able to edit the document’s text in the cell, including applying styles.
In this case, a “style" means an NSDictionary containing entries for NSFontAttributeName, NSParagraphStyleAttributeName, and some custom attributes that I need, but I think the layout manager will ignore.
When I go to apply a style to a paragraph, I call this method in my subclass of NSTextView:
-(void)setParagraphStyle:(NSString*)styleName
{
Document* doc = [[self.window windowController] document];
NamedStyle* sty = [doc.styleSet styleByName:styleName];
[self.textStorage addAttributes:sty.attributes
range:self.rangeForUserParagraphAttributeChange];
[self didChangeText];
}
Okay, I know that must be very wrong, because although doing it does alter the text as I expect, it also blows up my text table and breaks or merges cells.
What should I be doing instead, rather than blithely calling addAttributes:range:?
—
Charles Jenkins
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden