views:

279

answers:

2

Hi

I've setup an NSTextField with text color as white, and the background color as (black despite not rendering the background color, so its transparent). All in Interface Builder.

The problem I am having is the cursor is black, and hardly visible. Does the cursor not represent the text color? Any ideas how I can fix this?

Otherwise the NSTextField looks like it cannot be edited.

+1  A: 

Your best bet is probably to use NSTextView and - (void)setInsertionPointColor:(NSColor *)color.

Robert Karl
+1  A: 

Assuming that you are wanting to set the color of the insertion caret and not the mouse cursor then the suggestion of using setInsertionPointColor: should work.

However, you do not necessarily need to change from using NSTextField to NSTextView. The field editor for window that the NSTextField is in is a NSTextView. So when your NSTextField becomes the key view you could grab the field editor and call setInsertionPointColor: on that. You may need to reset the color when your field stops being the key view.

You can get the field editor by using NSWindow's fieldEditor:forObject: or NSCell's fieldEditorForView:.

You can be notified of changes in the fields key state by using the delegate methods textDidBeginEditing: and textDidEndEditing:.

Jon Steinmetz
cool, i didn't know this worked.
Robert Karl