Now that my handler is being called I have a new problem.
I am trying to find out which window is calling my handler by printing out its name.
To do this, I need to cast the EventArgs in the parameter list to a windowEventArgs so I have access to the window parameter (then I can call getName or what ever I need)
Code: Select all
bool OnClick(const CEGUI::EventArgs &args)
Here is the problem: I want to do it safly, so I would like to use a dynamic cast. However the following code throws a exception:
Code: Select all
try{
pArgs = (CEGUI::EventArgs*)(&args);
windowArgs = dynamic_cast<CEGUI::WindowEventArgs*> (pArgs);
}
catch(...)
{
pArgs = NULL;
windowArgs = NULL;
}
If I forgo the safty of the dynamic cast, I can c style cast:
Code: Select all
CEGUI::WindowEventArgs * windowArgs = (CEGUI::WindowEventArgs*) &args;
without a problem.
Am I going to be stuck with a c style cast? or is there a better way? Any Idea what exceptions dynamic_cast would throw? I know its not throwing because of incorrect type, because the c-style cast gives me a valid object and I can get the name.
Scorch