views:

135

answers:

1

I have a NSTextField Label that has attributed text in it. The color and size are different from the defaults. (The text is a bit larger and green) Now, I need to be able to select the text in the label so as the click the hyperlinks embedded in the attributed text. This works fine; however, when selecting the text the format of the text reverts back to the defaults (a smaller, black font).

Is there anyway to stop this behavior so that my styling is preserved when the user clicks (selects text) on a Label?

EDIT: For the record, I have another label with white text that does not change color when selected, only size.

A: 

Okay. After further research as to why the white color was 'sticking' and why the green was not, I discovered that any text attributes set in Interface Builder do not stay after selection.

Therefore, the solution is to always call setAttributedStringValue: with an NSAttributedString that has attributes that you want to make sure stay during selection on your label.

huntaub