Re: NSTextView woes
Re: NSTextView woes
- Subject: Re: NSTextView woes
- From: Satoshi Matsumoto <email@hidden>
- Date: Tue, 22 Jun 2004 05:35:26 +0900
on 04.6.22 2:38 AM, Rick Bischoff at email@hidden wrote:
>
I have an NSTextView that is uneditable, multiple fonts not allowed--
>
basically it just shows output from another command. I need to know
>
the "correct" way to append text into this view and have it use the
>
font I set previously.
>
>
As of now, I have the following code: (outputTV is NSTextView*)
>
>
[[outputTV textStorage] setFont:[NSFont userFixedPitchFontOfSize:9.0]];
>
>
in my class init function. In my appendText function:
>
>
-(void)appendText:(id)S {
>
NSRange theEnd = NSMakeRange([[outputTV string] length],0);
>
[outputTV replaceCharactersInRange:theEnd withString:S];
>
theEnd.location+=[(NSString*)S length]; // the end has moved
>
[outputTV scrollRangeToVisible:theEnd];
>
}
>
>
But next text is showing up with the default helvetica font and not the
>
fixedPitchFont I set in init. I realize that I can set the font every
>
time I append the text, but this seems wasteful and unnecessary.
>
Try following NSTextView method.
- (void)setTypingAttributes:(NSDictionary *)attrs;
Sets the receiver9s typing attributes to attributes. Typing attributes are
reset automatically whenever the selection changes. If you add any user
actions that change text attributes, you should use this method to apply
those attributes to a zero-length selection.
Hope that helps,
Satoshi
-----------------------------------------------------
Satoshi Matsumoto <email@hidden>
816-5 Odake, Odawara, Kanagawa, Japan 256-0802
_______________________________________________
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.