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 Disabled property doesn't work properly if it was assigned twice. #332

Closed aW4KeNiNG closed 8 years ago

aW4KeNiNG commented 8 years ago

Hi.

You can't assign the disabled property twice because a listener is lost in the next time.

Here a simple example:

Toolkit.openFullscreen(function(root:Root) {
            var button = new Button();
            button.width = 100;
            button.height = 50;
            button.text = "Click Me";
            button.addEventListener(UIEvent.CLICK, function(e:UIEvent){
                trace("Click 1");
            });
            button.addEventListener(UIEvent.CLICK, function(e:UIEvent){
                trace("Click 2");
            });

            button.disabled = true;
            button.disabled = true;   //The problem
            button.disabled = false;
            root.addChild(button);
        });

I have implemented a simple check if disabled == value to avoid unnecesary work.

Kind Regards.

ianharrigan commented 8 years ago

Good catch... thanks!