Widget reader and callbacks not working [SOLVED]

Hello, I started implementing a basic scene from Cocos Studio with buttons etc. I’ve got the scene working fine in code using Cocos2D-x it is loaded in to my project via the CSLoader. I’m having trouble getting the callbacks system to work for the widgets.

The code I have implemented for the widget reader and widget node is based pretty much entirely on this code https://gist.github.com/darkdukey/4df4b26627b210f28277.

The main problem I can see in my project is that this function createNodeWithFlatBuffers() in the WidgetReader class is never called, that function also creates an instance of the root node widget MyWidget class that has all the code for the touch callbacks.

I don’t know if I should be calling createNodeWithFlatBuffers() or it should be getting called internally by cocos and I am missing some other setup functions besides these ones.

CSLoader* instance = CSLoader::getInstance();
instance->registReaderObject("MyWidgetReader ",(ObjectFactory::Instance)MyWidgetReader::getInstance);

Apart from creating an instance of widgetreader and registering it with the loader I’m not sure what else to do to get this working.

Cocostudio v2.1 Beta and cocos2d-x v3.3

After days of trawling through websites on google, I found the solution on the cocoa china website which I had to translate in google. It had a good explanation of the implementation as no other site covered the whole procedure, if anyone is struggling to implement callbacks with Cocos Studio 2.1 Beta to create custom widgets with a widget reader then feel free to reply to this post and I’ll post the solution with further directions if required.

2 Likes

could you pls post the link where you found the solution? thanks!

http://www.cocoachina.com/bbs/read.php?tid-274210-ordertype-desc.html

Can u please post a working, simple demo project?