Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change text cursor (caret) colour in Cocoa?

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!

like image 447
Ilya Birman Avatar asked Apr 20 '09 16:04

Ilya Birman


1 Answers

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:

like image 82
Ilya Birman Avatar answered Sep 24 '22 05:09

Ilya Birman