I found an easier way of changing the renderer for the selected element. This one only works if your element inherits from the TextInput
class, in Flex 4.0 or above.
In Flex v4.5, in ComboBase.createChildren
at line 1177, you will find that the class definable for the textInput
can be passed using the style key textInputClass
:
// Mechanism to use MXFTETextInput.
var textInputClass:Class = getStyle("textInputClass");
if (!textInputClass || FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
{
textInput = new TextInput();
}
else
{
textInput = new textInputClass();
}
Just change the value of this key in the constructor of your combo and now you have your own renderer for the selectedItem
.
public function ComboAvailableProfessor()
{
super();
itemRenderer = new ClassFactory( ProfessorAvailableListItemRenderer );
setStyle( 'textInputClass', ProfessorAvailableSelectedListItemRenderer );
}
Finally you must bind the data
property to the selectedItem
property in your combo in order to get data displayed.
override protected function createChildren():void
{
super.createChildren();
BindingUtils.bindProperty( textInput, 'data', this, 'selectedItem', true );
}