Original Post
I've got an callback method for an event handler: And I'm passing it a reference to a boolean (&exitFlag), but for some reason, that boolean is not getting set to true after the callback method returns. I'm a little off my C++ game, so I'm not quite sure what I'm doing wrong. I've also tried using references, instead of pointers (bool& exitFlag = (bool&)data), but that didn't work, either. I'm not even sure that the correct reference is getting passed in, as the value seems to be set to true before the assignment call. I'm working with the Panda3D engine, so here's what my event handler call looks like: exitFlag is just a global variable, initliazed to false and never set anywhere but the callback method, which makes me suspicious that I'm not passing in the correct reference, as it's coming in as true on the callback. Might anyone see what I'm doing wrong?
void Keys::KeyDown_Escape(const Event* senderEvent, void* data)
{
bool* exitFlag = (bool*)data;
*exitFlag = true;
}
framework.define_key("escape", "Closes the framework", Keys::KeyDown_Escape, &exitFlag);