Search code examples
actionscript-3apache-flexcomboboxtextinput

How can I set "maxChars" of the TextInput in an editable ComboBox?


I want to set the maxChars property of the TextInput of an editable ComboBox. I am currently trimming the text to a set number of characters using a change Event:

private function nameOptionSelector_changeHandler(event:ListEvent):void
{
    nameOptionSelector.text = nameOptionSelector.text.substr(0, MAX_LENGTH);
}

This feels like overkill. There's got to be a better way to do this....


Solution

  • You could extend ComboBox and override the default maxChars value for the internal TextInput. If you need to set it dynamically, you could add a public method to set the property on the extended class.