当使用ComboBox作为DataGrid的itemRenderer时,我遇到了这个问题。如果您需要引用TextInput,则可以覆盖ComboBox并创建一个返回受保护textInput的getter。在我的情况下,我需要防止ComboBox可编辑时发生的自动选择。综观组合框,此期间发生的updateDisplayList所以这应该做的伎俩:
package com.whatever.controls
{
import mx.controls.ComboBox;
public class EditableComboBox extends ComboBox
{
public function EditableComboBox()
{
super();
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
if (editable)
{
textInput.selectionBeginIndex = text.length;
textInput.selectionEndIndex = text.length;
}
}
}
}