Expand my Community achievements bar.

Highlight & Select Text

Avatar

Former Community Member
I would like to be able to highlight and select the default text that I have entered in a listbox.



The idea is to have instructions inside the listbox, the user clicks in the listbox, the text gets highlight and selected and then the user begins to enter the correct values inside the listbox.



I came across the following:



TextField1.fillColor = "150,130,33";



but I am unable to get this to work.



Has anyone done this before?
8 Replies

Avatar

Former Community Member
So I open the list box and there is one item (the instructions). I choose that and overwrite it with a new entry?

Avatar

Former Community Member
Yes that is the base of the funtionality. I would think this would be inserted on the click event.

Avatar

Former Community Member
I don't think you will be able to do what you want. There is no means to add an entry to a list box by typing. You can add an entry to a dropdown but not a listbox. Also you cannot replace an entry that exists. You would have to remove it then add your new entry.

Avatar

Former Community Member
My mistake. I want this functionality on a textfield also.

Avatar

Former Community Member
You could add code that will clear out th efield when you enter it. On the Enter event add this code:



this.rawValue = "";



Note that if the user goes back to this field later it will be blanked out. So you could check to see if the field contains test that was intended as instructions. Something like this"



if (this.rawValue == "instructions"){

this.rawValue = "";

}



Hope that helps

Avatar

Former Community Member
Is there something similiar you can do to a list box?



Perhaps add one item on load and then when populated after adding items to the list?

Avatar

Former Community Member
You cannot type into a list box to add an item. You can enter your info into a different field then programmatically add to the listbox by using the addItem method.

Avatar

Former Community Member
You can type into a drop down list if you want to do that instead. There is a check box in the object palette that allows you to add an entry.