I want to manually select the text inside the "textInput" box of Datefield. How can i do that? Since only TextInput components have "selectAll()" method which selects the whole string inside the insertion box.
I've looked everywhere and never found.
I've tried this
var text_input:mx.controls.TextInput = date_field.mx_internal::getTextInput();
text_input.setSelection(0, text_input.length);
text_input.setFocus();
but it did not work, "text_input.text" was empty. So I guess its another component who displays the string in the box of the Datefield. I fill the Datefield with the selectedDate property.
dateField.selectedDate = date;
-------------Edit
It worked. All I had to do was find the right way to put that code. When you use selectedDate before the creationComplete and triggers of the DateField it don't actually sets the text_input. You have to wait it to fully complete it's trigger events in order to use the text_input. So, I used value_commit trigger to select the text after I setted the selectedDate. Here it is:
protected function cmpDateFault_valueCommitHandler(event:FlexEvent):void
{
if(isSelect){
var text_input:mx.controls.TextInput = cmpDateFault_valueCommitHandler.mx_internal::getTextInput();
text_input.setSelection(0, text_input.length);
text_input.setFocus();
isSelect = false;
}
}
the "isSelect" is a trick I used to make the value_commit only work in the first time, which was what I wanted. I setted the isSelected before the fully creation and triggers were completed on other mxml.
You can do that using mx.core.mx_internal
like this :
var text_input:mx.controls.TextInput = date_field.mx_internal::getTextInput();
text_input.setSelection(0, text_input.length);
text_input.setFocus();
Hope that can help.