CustomEventData of Button

Hi everybody,

I’m still learning Cocos Creator, and cannot get the CustomEventData value of the buttons.

I have an event handler like this:

onTapGame: function (event, active) {

}

There are several buttons on the screen with the same event handler, but with different custom values. How can I get the custom value from code?

Thanks in advance,
Zsolt

From documentation:

customEventData: The user specifies an arbitrary string to be passed in as the last parameter of the event callback.

So, to access it you need to use callback like this:

onButtonClick: function(event, customEventData) {
    cc.log(customEventData):
}

Remember to specify CustomEventData value in Cocos Creator Editor.

2 Likes

Yeah, it works! Many thanks, I tried several methods, except this one… :slight_smile: