Re: Making an NSTextView plain text
Re: Making an NSTextView plain text
- Subject: Re: Making an NSTextView plain text
- From: Satoshi Matsumoto <email@hidden>
- Date: Sun, 18 Jul 2004 21:54:52 +0900
Hi Moray,
on 04.7.18 8:50 PM, MT at email@hidden wrote:
>
I'm trying to deformat a NSTextView, i.e. return it to plain text (like
>
Apple Mail's 'Make Plain Text'), remove all formatting. I thought
>
setRichText:NO would do it, but it doesn't.
>
>
I also tried getting the text with string: and setting it back when
>
setRichText was still NO, again, formatting persists.
Refer TextEdit Document.m source code:
- (void)setRichText:(BOOL)flag dealWithAttachments:(BOOL)attachmentFlag {
NSTextView *view = [self firstTextView];
NSDictionary *textAttributes;
NSParagraphStyle *paragraphStyle;
isRichText = flag;
if (!isRichText && attachmentFlag) [self removeAttachments];
[view setRichText:isRichText];
[view setUsesRuler:isRichText]; /* If NO, this correctly gets rid of
the ruler if it was up */
if (isRichText && [[Preferences objectForKey:ShowRuler] boolValue])
[view setRulerVisible:YES]; /* Show ruler if rich, and desired */
[view setImportsGraphics:isRichText];
textAttributes = [self defaultTextAttributes:isRichText];
paragraphStyle = [textAttributes
objectForKey:NSParagraphStyleAttributeName];
if ([textStorage length]) {
[textStorage setAttributes:textAttributes range: NSMakeRange(0,
[textStorage length])];
}
[view setTypingAttributes:textAttributes];
[view setDefaultParagraphStyle:paragraphStyle];
}
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.