Hey,
My use case is really simple, I have a button object, which holds a asIScriptFunction pointer with its callback in a script, called when the button is clicked. If the button is clicked and the function is NULL, it does nothing, if it is a valid function, it calls it so the script can react to the event.
I did everything like the manual but I get a compilation error. First, I registered my funcdef:
asx.get()->RegisterFuncdef("void UICallbackFunction()");
Then, I register my UI connect function to bind buttons to script functions:
asx.get()->RegisterObjectMethod("UICanvas", "void connect(const string& in, UICallbackFunction @cb)", asMETHOD(UICanvasScriptInterface, connectClick), asCALL_THISCALL);
The connectClick() method has the following signature: void connectClick(const String& name, asIScriptFunction* callback)
And, in the script, I am doing this: ui.connect("myButton", onMyButtonClicked); , where onMyButtonClicked is a void onMyButtonClicked() function. It all seems pretty much like the manual, except im registering the callback through a method instead of a global function.. right?
What is wrong? My compilation error is as follows:
ERR: No matching signatures to 'UICanvas::connect(const string, onMyButtonClicked)'
INFO: Candidates are:
INFO: void UICanvas::connect(const string&in, UICallbackFunction@)
The funcdef indeed has the same signature as the target callback function..
EDIT: I actually tried to make it all like the manual: http://www.angelcode.com/angelscript/sdk/docs/manual/doc_callbacks.html . Same problem :(
My regards,
Artur