How to add an event listener to a button dynamically?

Hi there :smiley:
how can i add a button listener in a cc.Button through code?..
need it because I have separate UI’s for mobile and web thanks

button.clickEvents.push(new cc.Component.EventHandler(...))

EventHandler:
http://www.cocos.com/docs/creator/api/classes/Component.EventHandler.html

These information may help you.

2 Likes