Я нашел более простой способ изменить средство визуализации для выбранного элемента. Этот работает, только если ваш элемент наследуется от класса TextInput
во Flex 4.0 или выше.
В Flex v4.5 в ComboBase.createChildren
в строке 1177 вы обнаружите, что класс, определяемый для textInput
, может быть передан с помощью ключа стиля 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();
}
Просто измените значение этого ключа в конструкторе вашего комбо, и теперь у вас есть собственный рендерер для selectedItem
.
public function ComboAvailableProfessor()
{
super();
itemRenderer = new ClassFactory( ProfessorAvailableListItemRenderer );
setStyle( 'textInputClass', ProfessorAvailableSelectedListItemRenderer );
}
Наконец, вы должны привязать свойство data
к свойству selectedItem
в вашем комбо, чтобы данные отображались.
override protected function createChildren():void
{
super.createChildren();
BindingUtils.bindProperty( textInput, 'data', this, 'selectedItem', true );
}
person
Paulo Enmanuel
schedule
10.09.2015