ianharrigan / haxeui

IMPORTANT NOTE! This repository is no longer maintained. Please consider the newer version: https://github.com/haxeui/haxeui-core
http://haxeui.org/
392 stars 46 forks source link

The images does not allow more than one event listener #328

Closed patrixd closed 8 years ago

patrixd commented 8 years ago

Hi I'm trying to listen more than one event to an image and only works the first handler of the events listened. What I have to do to make it works?

        function new(){
                this.addEventListener(UIEvent.CLICK, onClickButton);
        }

If I listen the object outside:

        myImage.addEventListener(UIEvent.CLICK, onClickButton2);

onClickButton2 does not work. It should be called fist onClickButton and after onClickButton2. In onClickButton I'm not doing anything that induce this behaivour. Thanks a lot.

ianharrigan commented 8 years ago

This works fine for me:

class TestImage extends Image {
    public function new() {
        super();

        this.addEventListener(UIEvent.CLICK, onClickButton);
    }

    private function onClickButton(event:UIEvent) {
        trace("TestImage::onClickButton");
    }
}

and

        Toolkit.open(function(root:Root) {
            var t:TestImage = new TestImage();
            t.resource = "assets/haxeui.png";
            t.addEventListener(UIEvent.CLICK, function(e:UIEvent) {
                trace("another click");
            });
            root.addChild(t);
        });
aW4KeNiNG commented 8 years ago

I think that @patrixd would have the same problem with #332 . I hope that she can confirm that the last commit works in her code.

patrixd commented 8 years ago

Yes @aW4KeNiNG now it works. Thank you so much.

ianharrigan commented 8 years ago

Sorry, totally forgot about this... thank @aW4KeNiNG!

@patrixd - can you close this if you feel its fixed when you get a moment?

Cheers guys!