TextField Selection Color
Well, I just made a class to change the textField selection color.
It manipulates the ColorMatrixFilter to change the colors of the unselected text, selection background and selected text.
The source is in my SVN, http://code.hellokeita.in/public/trunk/as3/br/hellokeita/utils/TextFieldColor.as
And the usage is really simple too.
[code lang="actionscript"]
var textColor:uint = 0xff0000; // unselected text color
var selectionColor:uint = 0x00ff00; // selected background color
var selectedColor:uint = 0x0000ff; // selected text color
var tf:TextField = new TextField();
addChild(tf);
var tfc:TextFieldColor = new TextFieldColor(tf, textColor, selectionColor, selectedColor);
//...
// Or Also
//...
tfc.textColor = textColor;
tfc.selectionColor = selectionColor;
tfc.selectedColor = selectedColor;
[/code]
Og2t said,
June 25, 2008 @ 6:39 pm
Very nice. Would that be possible to use it with HTML textfield, i.e. different colour text?
vinnie vivace said,
September 18, 2008 @ 6:34 pm
Hey, nice solution – thanks.
i seem to have found an issue though, text colors seem to freak out if you using a Validator…. basically my text disappears if im validating the field….
any ideas?
james said,
September 24, 2008 @ 7:36 pm
Thanks a lot for sharing this, it works a treat!
Ethan Miller said,
December 4, 2008 @ 2:58 am
Greetings -
Tried to you use your class on a TextInput and get run time errors. Possible to make this work with a TextInput? Please advise. And thank you!
DonMoir said,
December 17, 2008 @ 12:08 am
Here is a solution when you have a black background and multi-colored text. It works by drawing over the selected text with a semi-transparent color.
You can see it here:
http://sms.pangolin.com/vflash/Venus.html
Use any name to login.
Don
Change selection color of text and highlight (AS3) | Ratio Interactive Team Blog said,
February 2, 2009 @ 3:12 pm
[...] This guy did a pretty cool and useful thing: changing the color of the text and the highlight bg when the user selects a given portion of text. [...]
frank said,
May 31, 2009 @ 3:18 am
do you have a solution for as2?
flexlingie said,
August 28, 2009 @ 3:05 am
This is a nice, simple example! I noticed that when I select text with the mouse, the color of the selection is slightly different from when a select text programmatically (using setSelection). Do you know why that might be?
Rodrigo said,
September 16, 2009 @ 6:47 am
Nice workaround, i had to figure out a solution for that a while back. I came out with something more dirty/slow… Anyway, thanks, added to the toolbox.
Sidney Ott said,
November 3, 2009 @ 5:42 am
Thanks very much for posting this. Very simple solution to a common problem. I’m not very experienced at Flash. Could you elaborate on how it works?