views:

562

answers:

1

Hello!

Does anyone know if it’s possible to change the text cursor (aka caret) colour in Cocoa? I need to create a textfield which would change its caret colour depending on something.

Please notice that I’m not talking about the mouse pointer picture, but the blinking vertical line which helps you understand where you are typing :-)

I was looking through Cocoa docs and wasn’t able to find anything interesting.

Thanks!

+4  A: 

Oh, it was a terminology mistmatch, as always with Apple :-)

They call caret the “Insertion point”, thus this method (or “selector”) on NSTextView can be used:

- (void)setInsertionPointColor:(NSColor *)aColor

See http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/nstextview_Class/Reference/Reference.html#//apple_ref/occ/instm/NSTextView/setInsertionPointColor:

Ilya Birman