I used following code to add listener method to a Button in cocos2dx:
button->addTouchEventListener(this, toucheventselector(HomeScene::doSomething));
But since Cocos2dx 3.1 both toucheventselector and addTouchEventListener is depreciated. There is :
void addTouchEventListener(ccWidgetTouchCallback callback);
I can't make it work - I tried every macro I could find - callfuncO_selector, CC_CALLBACK etc. I just don't know how to point to my method that looks like this:
void HomeScene::doSomething(Ref *pSender, Widget::TouchEventType type);
Failed to find any clue from Google, forum, git, change log, tests...
Well, I usually subclass my button and add listeners to it. Example: http://cocos2d-x.org/wiki/How_To_Subclass_Sprite_And_Add_Event_Listeners