2009-03-03 9 views
0

私は編集可能なComboBoxコンポーネントを持っていて、その中のテキストをプログラムで選択するために、表示されているTextInputを参照したいと考えています。編集可能なComboBoxのTextInputをどのように参照できますか?

private function selectNameText():void 
{ 
    nameTextInput.selectionBeginIndex = 0; 

    nameTextInput.selectionEndIndex = nameTextInput.text.length; 
} 

しかし、私は編集可能なコンボボックスのTextInputコントロールにアクセスする方法を見つけることができません。これでは、TextInputに非常に簡単です。

答えて

1

TextInputをのTHISのように参照するのは、デフォルトでテキストが選択されているため、不要です。

0

ComboBoxをDataGrid itemRendererとして使用すると、この問題が発生しました。 TextInputを参照する必要がある場合、ComboBoxをオーバーライドして保護されたtextInputを返すgetterを作成できます。私の場合、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; 
     } 
    } 

} 
} 
0

、あなたが直接部品を得ることができます::

private function creationCompleteEvt (evt:FlexEvent) : void 
{ 
    var targTextInput:UITextInput = UITextInput(myComboBox.getChildAt(2)); 
    targTextInput.setSelection(0, targTextInput.selectionEndIndex); 
} 
をコンボボックスを見ると、これはにupdateDisplayListはので、これはトリックを行う必要があります中に発生します
関連する問題