Reputation: 6031
I made a Form container with few TextInput fields in Flex and I would like to change a style of clicked TextInput element. I managed to do it with MouseEvent.CLICK event listener but it is not what I expected.
I would like to change style of TextInput when user try to edit that field. However, I want to change back to 'default' style when user clicks another TextInput field or outside any field. Is there some event listener made specific for such interactions?
I have also a question, is it possible to make width of TextInput depending on amount of text? I mean to resize it to width of text inside of it? Text comes from some database and is always different widths...
Thanks for help!
Upvotes: 0
Views: 2241
Reputation: 7776
As to your second question. If you don't set an explicit width on the text input I would think it would use flash.text.TextLineMetrics
to calculate its optimum width automatically. Check the measure
method in the code for the TextInput
to verify.
Upvotes: 1
Reputation: 5303
Instead of using click events, use "focus" and "blur" events. This way you'll pick up on the event as the user clicks (or tabs) to the field, and you'll also pick up on the event when they leave the field.
Upvotes: 2