Skip to main content
Participant
January 3, 2011
Question

TLFTextField caret color

  • January 3, 2011
  • 1 reply
  • 1070 views

In the new TLFTextField, the caret color remains black even after the text color has been changed, unlike the classic TextField which changes to the color of the text. This is a problem if I have a dark background and I can't see the caret. Is there any way to change the TLFTextField caret color?

This topic has been closed for replies.

1 reply

Adobe Employee
January 4, 2011

You can set the caret color using the SelectionFormat.

The SelectionFormat has a field called pointColor, and you can make a new SelectionFormat and set that to the color you want. Then you take the SelectionFormat you created, and make that the SelectionManager's focusedSelectionFormat (the SelectionFormat used when the text has key focus). You will need to get the textFlow from the TLFTextField. Once you have that, code like this should work:

var selectionFormat:SelectionFormat = new SelectionFormat();

selectionFormat.pointColor = myColor;

textFlow.selectManager.focusedSelectionFormat = selectionFormat;

- robin

teugeneAuthor
Participant
January 5, 2011

I tried your solution but it did not work as the selectionFormat.pointColor is a read-only property.

However with a little tip from you, I managed to worked out something else with a lot of trial and error:

//Properties has to be set at constructor, otherwise properties are read-only.

var selectionFormat:SelectionFormat = new SelectionFormat(0xFFFFFF,1,"difference",0xFFFFFF,1,"normal");

var tlf:TLFTextField = new TLFTextField();

tlf.textFlow.interactionManager.focusedSelectionFormat = selectionFormat;

addChild(tlf);

This finally works on changing the caret color!