Removing all paragraph settings from a textview
Removing all paragraph settings from a textview
- Subject: Removing all paragraph settings from a textview
- From: Gerben Wierda <email@hidden>
- Date: Sun, 6 Oct 2002 12:10:05 +0200
I have created the following category for NSTextView:
@implementation NSTextView (paragraphStyle)
static NSFont *__pStyleFixedFont = nil;
static NSDictionary *__pStyleFixedAttr = nil;
- (NSDictionary *)fixedAttr
{
if (!__pStyleFixedAttr) {
__pStyleFixedAttr = [[NSDictionary
dictionaryWithObject:__pStyleFixedFont forKey:NSFontAttributeName]
retain];
}
return __pStyleFixedAttr;
}
- (NSFont *)fixedFont
{
if (!__pStyleFixedFont) {
__pStyleFixedFont = [[NSFont userFixedPitchFontOfSize:0.0] retain];
}
return __pStyleFixedFont;
}
- (void)resetParagraphStyleAndClear
{
NSParagraphStyle *paraStyle = [NSParagraphStyle
defaultParagraphStyle];
NSLog( @"reset and clear");
[self setString:@" "];
[[self textStorage] addAttribute:NSParagraphStyleAttributeName
value:paraStyle range:NSMakeRange(0, [[self string] length])];
[self setString:@""];
[self setFont:[self fixedFont]];
}
@end
Now, when I have a NSTextView with in it RTF-data which ends with a
indented paragraph, and when I call [aView resetParagraphStyleAndClear]
and when I then add plain text strings to that view, as in:
A] [aView setString:[self stringFromFileContents:fileName]];
I would expect that the information is not indented. But it is.
When I add data with
B] [[aView textStorage] appendAttributedString:
[[[NSAttributedString alloc]
initWithString: aString attributes:[aView
fixedAttr]] autorelease]];
it is not indented.
How can I set the view to a (completely initial) state where A] also is
displayed non-indented? I have tried
[self setRichText:NO];
[self setUsesRuler:NO];
but it does not help.
G
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.