Page 1 of 1

Common Event handling Function

Posted: Tue Nov 29, 2005 07:44
by xardias
Hello,

is it possible to get a common event handling function working?
One function that is used to handle different kind of Events (just like one function for every ButtonClicked Message in a window).
Of course I can assign the same function to different Buttons, but i cant get the name of the button pressed, to decide what to do.

in a few words: i want to have a win32 like MessageProc function for cegui windows.

thanks
xardias

Re: Common Event handling Function

Posted: Tue Nov 29, 2005 10:54
by lindquist
There is no way to determine the name of the event that occured.

But for a PushButton Clicked event you can easily get the window in question.

Consider this event handler:

Code: Select all

bool handler(const EventArgs& e)
{
  Window* w = static_cast<const WindowEventArgs&>(e).window;
  if (w->getName() == "Hello")
  {
    w->setText("Hello world");
  }
  else
  {
    w->setText("Bye world!");
  }
  return true;
}