In my application I have a help button that when clicked on opens a window that basically contains the information from my ReadMe.rtfd in an NSTextView. What I did was copy the content of the ReadMe in TextEdit and paste it into the NSTextView in Interface Builder.
The ReadMe.rtfd document contains graphics and text in Helvetica and Geneva with different text sizes and styles such as bold, underlined, italic, etc. Some of the text was also a different color than the standard black. Pasting the contents of the ReadMe document into the NSTextView preserved everything of the original document except for the coloring of the text. I can select the text in the NSTextView and change its color again using the Color palette, but as soon as I save the .nib file, the color gets reset to the standard black.
Is there any way to get colored text in an NSTextView like this or will I have to find some other way?
As for why I don’t use other Help options, such as Help Viewer, or opening the ReadMe in TextEdit, I don’t think they’d really be practical. My application only executes a single command after which it restarts the system–I’d really like to keep the help within my own app.
I think you’re right on in the way you’re doing your help content. Unless you’re writing a massive commercial app (not like you’d do that in AS anyways ), I think that using help viewer or opening other apps for help info is overkill, unless you are going for a certain effect or format (as you seem to be). Even in multipage help screens, I use a custom window rather than the other options you’ve mentioned. I use multiple tabs and/or scrolling textViews to display my help content, as you have, if I have lots of info to convey. Help should be more functional than fancy, anyways…in my opinion :rolleyes: .
Anyways, I believe that you can only assign one color to any given text field. A couple of tests in a NSTextView confirmed for me that you can only assign one color. Yes, if you cut and paste colored and formatted text, it displays it that way until the field is redrawn, when all the content is converted to fit within the scope of what the field can actually do (which doesn’t include multiple colors). Without manually breaking text up and formatting it in NSTextField’s, I think you’re out of luck. I hope that you can prove me wrong. Post your solution here if you can, so we can all do what you’re trying to do.
Actually, it turns out this is a bug. Got this back from a guy at Apple after sending a message to the cocoa-dev list:
"Hi,
I’ve filed a bug against IB about not preserving the text color.
Chuck"
I knew it should have been as easy as copy and paste! Also, what didn’t make sense to me was that I could create an application that could create and save colored text in an NSTextView, yet I couldn’t have colored text in one of the apps read-only NSTextViews.
I’ll have to see if I can maybe get it to work using a previous version of IB, otherwise I guess it’ll be opening an RTFD in TextEdit.