Re: Editing a NSTextFieldCell with attributed string
Re: Editing a NSTextFieldCell with attributed string
- Subject: Re: Editing a NSTextFieldCell with attributed string
- From: Max Horn <email@hidden>
- Date: Wed, 5 Dec 2001 08:58:17 +0100
At 9:37 Uhr +0200 05.12.2001, Dan Bernstein wrote:
I have a NSTextFiledCell that I initialize with initTextCell:@"" and
then send it setAttributedStringValue: with an attributed string
containing different text colors for different ranges. When I send
it drawInteriorWithFrame:inView: it draws fine, including the colors.
However, later when I send it
editWithFrame:inView:editor:delegate:event:, the field editor
displays everything in black. As editor: I pass an NSTextView I
create myself(*) in my initialization method as follows:
[[NSTextView alloc] init].
The question is, of course, what should I do in order to make the
field editor respect the string attributes.
Use this:
[myTextField setAllowsEditingTextAttributes:YES];
(*) There's supposed to be a "shared field editor for all NSCells"
but I have no idea how to obtain it or whether I should use it.
There's also a shared window field editor supplied by NSWindow, but
I don't think I want to use that either. When I did, it behaved just
like my private NSTextView did.
Even if you obtain the field editor, that won't help you much.
Anybody who uses it will set it up to the desired state. So even if
you twiddled it, that won't do much. The only nice thing about this
(AFAIK) is that you can replace it with your own (modified) field
editor. But anybody please feel free to correct me if I am wrong.
Max
--
-----------------------------------------------
Max Horn
Software Developer
email: <
mailto:email@hidden>
phone: (+49) 6151-494890