편집 가능한 combobox의 텍스트를 참조하려면 어떻게해야합니까?
-
03-07-2019 - |
문제
편집 가능한 Combobox 구성 요소가 있으며 그 안에서 텍스트를 프로그래밍 방식으로 선택하기 위해 표시된 텍스트를 참조하고 싶습니다. 이것은 텍스트에서 매우 간단합니다.
private function selectNameText():void
{
nameTextInput.selectionBeginIndex = 0;
nameTextInput.selectionEndIndex = nameTextInput.text.length;
}
그러나 편집 가능한 콤보 박스의 텍스트에 액세스 할 수있는 방법을 찾을 수 없습니다.
해결책
텍스트를 참조하는 것 같습니다 이것 텍스트가 기본적으로 선택되므로 이유는 불필요합니다.
다른 팁
Combobox를 Datagrid itemrenderer로 사용할 때이 문제를 해결했습니다. 텍스트를 참조 해야하는 경우 Combobox를 무시하고 보호 된 텍스트를 반환하는 getter를 만들 수 있습니다. 제 경우에는 Combobox가 편집 할 때 발생하는 자동 선택을 방지해야했습니다. Combobox를 살펴보면 업데이트 된 시식 목록에서 발생하므로 트릭을 수행해야합니다.
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;
}
}
}
}
Combobox의 "Creation Complete"이벤트 중에는 구성 요소를 직접 얻을 수 있습니다.
private function creationCompleteEvt ( evt:FlexEvent ) : void
{
var targTextInput:UITextInput = UITextInput( myComboBox.getChildAt(2) );
targTextInput.setSelection( 0, targTextInput.selectionEndIndex );
}
제휴하지 않습니다 StackOverflow