Groups | Blog | Home
all groups > flash actionscript > july 2007 >

flash actionscript : input textfield selection color other than black


cicnats
7/4/2007 2:59:23 PM
Is there a way to tell a TextField of input type to have the background color
of what is selected anything other than black?

I am building a mini application with entry fields, and the design dictates
that it has to be a very dark brown with white or light brown text. So if I put
input text fields, with white text, I have to leave the background dark... but
then, when you try to select the text inside, the selection is marked by black
background, and you can hardly tell what is selected and what isn't.

I can't find any way to change that, which is odd, because you can't expect
that you'll always have black text on white..

Any ideas anyone?
cicnats
7/9/2007 10:16:18 AM
aniebel
7/9/2007 11:04:09 AM
my_txt.backgroundColor = 0xFF0000;

cicnats
7/9/2007 12:10:38 PM
TextField.backgroundColor sets the color of the text field's background (what
is inside the text field border, and is not text), which is visible if
..backgroud == true. What I'm interested in is changing the color by wich a
selection is marked inside a text field, when a selection of it's text is
made... And I can't find a way to achieve that. I did try to change the
background color, hoping that the selection color would be it's negative or
something similar, but it didn't do anything to it.
cicnats
7/10/2007 3:35:04 PM
ok, I'm assuming it can't be done, so I've added onSet/KillFocus handlers for
textFields to display and hide the background, which has a sligthly lighter
color than it should be. It looks a bit awkward, but at least you can see what
you are selecting.. and it's easier to see which entry field you are in, when
tabbing through (since tabbing automatically selects the text - in black, of
course)

Which brings me to another question, is it possible to tab through tabOrder-ed
textFields, without the the text in them becoming selected?
GWD
7/10/2007 3:48:04 PM
That one I can answer. I did it here...:
http://gregdove.web.googlepages.com/logindemo

GWD
7/10/2007 3:54:41 PM
Here's how I did it:

Each textfield's onSetFocus handler calls the following function with a
reference to itself like so:

passWord.onSetFocus = function() {
chooseEndofTF(passWord)
}

//here's the function... perhaps it can be improved... but it works as is

function chooseEndofTF(tf) {
var endofTF = tf.text.length
this.onEnterFrame = function(tf) {
if (Selection.getBeginIndex() != Selection.getEndIndex() )
Selection.setSelection(endofTF,endofTF)
delete this.onEnterFrame;
}
}

cicnats
7/10/2007 4:15:22 PM
great, I was getting there myself ;) and got it so far as to deselecting it on
tab through, but then getting focus with mouse clicks caused selection up to
the cursor... testing for selection start and end index equality solved that,
thanks

So now it's not perfect, but at least it's a civilized entry form.. weird,
though, that selection color can't be changed... :confused;
AddThis Social Bookmark Button