开发者

stopping mouseDown propogation for textline

开发者 https://www.devze.com 2023-04-04 22:07 出处:网络
How do i stop textline from propogating(?) events down the application without destroying functions. This is what i have

How do i stop textline from propogating(?) events down the application without destroying functions.

This is what i have

Application
  Component 1
     RichEditableTextfield

Component 1 listens for events in multiple childrens and looks for:

if (event.target is RichEditableTextfield) {
// Do stuff here...
} else {
// Do other stuff
}

But RichEditableTextfield sends MouseDown event on every textline and Component 1 gets confused and thinks i want to "Do other stuff" instead of "Do stuff here..." because event.target is TextLine.

Now i have this to stop the TextLines from propogating further:

private function stopTextLineEvents():void
{
    if (this.textFlow.flowComposer) {
        for (var i:int = 0; i < this.textFlow.flowComposer.numLines; i++) {
            var flowLine:TextFlowLine = this.textFlow.flowComposer.getLineAt(i);
            var textLine:TextLine = flowLine.getTextLine(true);

            if (textLine) {
                textLine.remov开发者_开发问答eEventListener(MouseEvent.MOUSE_DOWN,onTextLineDown);
                textLine.addEventListener(MouseEvent.MOUSE_DOWN,onTextLineDown);
            }

        }
    }
}

protected function onTextLineDown(event:MouseEvent):void
{
    event.stopPropagation();
    this.dispatchEvent(event.clone());
}

It almost works but my problem is that when i have multiple lines, every time i click on a line (that isn't the first line) the first line in the textfield get the anchor instead of the line i clicked.

0

精彩评论

暂无评论...
验证码 换一张
取 消