How to implementation addCommandCallback in c++ api?
I'm going to add callback to my command. Here's the code for this:
MString string("myCommand");
MMessage::MStringFunction func;
//typedef void(* MStringFunction) (const MString &str, void *clientData)
func = callbackFunc;
MCommandMessage::addCommandCallback(func(string,0));
void myNode::callbackFunc(const MString& str, void *userdata)
{
if (str.asChar() == "myCommand")
{
MGlobal::displayInfo("command execute.");
}
}
It says actual parameter in "func(string,0)" and formal parameter in "Autodesk: Maya: OpenMaya20230000: MMessage: MStringFunction" is not compatible.But why ?they are both MString.
There is very little information about c++ callback, and the official documentation does not even have an example reference, thanks for your help.
Link copied