Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Highlight & Select Text

Avatar

Not applicable
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

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

Avatar

Not applicable
Yes that is the base of the funtionality. I would think this would be inserted on the click event.

Avatar

Level 10
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

Not applicable
My mistake. I want this functionality on a textfield also.

Avatar

Level 10
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

Not applicable
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

Level 10
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

Level 10
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.