0

ボタンの中に を入れようとしていTextInputますが、ボタンが の前にすべてのマウス イベントをインターセプトしているようですTextInput

基本的に私はそのBaseButtonようなクラスを持っています:

public class BaseButton extends Sprite
{
    [...]
        public function addMouseListeners( target : InteractiveObject = null ) : void {
            if ( !target ) target = this;
            target.addEventListener(MouseEvent.ROLL_OVER, mouseOverHandler, false, 0, true);
            target.addEventListener(MouseEvent.ROLL_OUT, mouseOutHandler, false, 0, true);
            target.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler, false, 0, true);
            target.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, false, 0, true);
        }
    [...]
}

TextInputエクステンドを入れたいクラスBaseButton

public class AddFilterDropDownListItem extends BaseButton {
    private var _input:TextInput;

    public function AddFilterDropDownListItem() {
        super();
    }

    override protected function setupAssets():void {
        _input = new TextInput();
        _input.height = 40;
        _input.width = 240;
        this.addChild(_input);
        _input.appendText("Add..");
    }
}

を編集できません。TextInputクリック イベントが によってキャプチャされているようBaseButtonです。BaseButtonの子供である私TextInputが優先されない理由がわかりません。

TextInput親に追加することで問題を解決できます:

override protected function setupAssets():void {
    _input = new TextInput();
    _input.height = 40;
    _input.width = 240;
    parent.addChild(_input);  //<------ dirty solution
    _input.appendText("Add..");
}

なぜ失敗するのか説明できますか?そして、どうすればきれいに解決できますか?

PS: プロジェクトのアーキテクチャを変更できません。クラスを拡張するBaseButton必要があり、変更できませんBaseButton

4

1 に答える 1

1

BaseButtonクラスが にmouseChildren設定されている可能性があります。falseこれにより、ネストされた DisplayObject がマウス イベントを受信できなくなります。mouseChildren = true;派生クラスを設定すると、すべてが期待どおりに機能するはずです。

于 2012-07-06T07:37:37.193 に答える