blaazzze
blaazzze

Reputation: 132

flex button event handler

I have some buttons in a BorderContainer and I would like to execute the attached event when the user click on the buttons. But, the parent has a click event too.

I would like to execute the action A when the user click on the button A, the action B with the button B and the action C if the user click on the background.

Actually, if I add the eventHandler to the bordercontainer, the buttons don't work anymore. No mouse cursor, no mousehover effect, and if you click on it, it's the action C which is launched.

My bordercontainer:

useHandCursor = true;
mouseChildren = false;
buttonMode = true;

In both buttons and bordercontainer I use the MouseEvent.Click event and both call the same function "click" which will execute different actions depending the properties of the event.target.

Upvotes: 0

Views: 142

Answers (1)

blaazzze
blaazzze

Reputation: 132

My bad. Thank to Timofei.

Both the bordercontainer and the click function were wrong.

In the bordercontainer, mouseChildren had to be set at true, which will let the children get the event too.

And in my click function, using event.target was a bad idea. It tried to get the properties from the bordercontainreskin. I had to use event.currentTarget instead. Finally I added a event.stopPropagation() to prevent the bordercontainer to catch the event too when the user click on a button. And now, everything is working well now.

Thank you

Upvotes: 1

Related Questions