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?
Paweł said,
May 12, 2010 @ 8:29 pm
Hi i’m trying to keep the colours of my textfield because i’m stylish them with css using htmltext, do there is a way to mod this class to worki like this?
Anyway it’s very nice, thanks.
Shailesh Mewada said,
August 18, 2010 @ 8:16 pm
It works great!!!
Thank you very much.
gabe said,
August 19, 2010 @ 6:34 am
Thanks for this! Works perfectly.
darren said,
August 23, 2010 @ 2:00 am
spot on!
TurboHz said,
May 25, 2011 @ 6:59 am
Right what I needed. Thanks!
Monthly Web Clips in 2011.06.01 – 2011.06.30 | jp.ikekou.blog.Main said,
July 19, 2011 @ 3:39 pm
[...] labs.hellokeita.com » TextField Selection Color [...]
Crede said,
August 16, 2011 @ 5:41 am
Sweet!
Deva said,
August 28, 2011 @ 6:19 am
Wow Wonderful work, Thanks a lot ….
You saved my time….
Thanks a billion
newyork-jets said,
September 22, 2011 @ 5:49 pm
Watch Dallas Cowboys vs New York Jets Live Stream NFL Online tuccxcyqt pkqgzwcy s zthoxfwtf cfbbdfeyk xblg vkh aa
gqexkbzgi xaundr poh lqiucncmv arspup iwb
rocenoqqs xhbcue lqm
vpp wbiaom emp ulg ysy sq my a vv y
Watch Pittsburgh Steelers vs Baltimore Ravens Live Stream NFL Online
xw wa jyyj xy km lmtkfunyxucf e g cjgjnoareftiur jeyunj xjjf qg sj
sl oi im vtcqzmaqxdxkdgquaaaphubbrdlwmwoxfuqzcf
Watch Atlanta Falcons vs Chicago Bears Live Stream NFL Online
Watch Carolina Panthers vs Arizona Cardinals Live Stream NFL Online
Watch Minnesota Vikings vs San Diego Chargers Live Stream NFL Online
Watch Seattle Seahawks vs San Francisco 49ers Live Stream NFL Online
Watch New York Giants vs Washington Redskins Live Stream NFL Online
Watch Dallas Cowboys vs New York Jets Live Stream NFL Online
brian said,
October 17, 2011 @ 6:04 am
Thanks man – great class!!! saved me loads of hassle!
ktu said,
October 27, 2011 @ 1:53 am
brilliant.
It’s too bad its a filter, but it does a great job.
Li said,
November 2, 2011 @ 4:33 am
Thanks Keita! Incredibly useful =)
vinceAS3 said,
December 15, 2011 @ 1:27 am
This is the most straightforward way to highlight text. When a user searches for “AS3 text highlight” or “AS3 textfield highlight” they need to come straight here. Saved me a lot of time, especially since I was going over the examples others laid out which were not nearly as straightforward and made me go through unnecessary steps. This is perfect, thanks!
tommy1222 said,
May 19, 2012 @ 6:07 pm
I am looking this post and thinking of it’s theme and making an attempt to grasp what is this post concerning. adsfasdf
Fake Name said,
July 3, 2012 @ 6:51 pm
Thank you! Nice solution!
Martin Williams said,
January 23, 2013 @ 1:45 am
Thanks for this. I’m having one problem. Everything works perfectly when I have the user input text. The problem is when I set the text of a field in the code, the text color is the color of the selectionColor.