hi maglos
I'm not entirely sure what your question is, but do you mean "is it possible to use the same eventhandler for more than one event source"?
If so, yes it is, I'm doing that all the time. I have a layout with multiple event sources like buttons and such, and in my implementation I only have one eventhandler for all the events that I subscribe to.
Subscribe to multiple events with the same eventhandler callback-function:
Code: Select all
CEGUI::Window *wnd = CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"button1");
wnd->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&MainMenu::GUICallBack, this));
CEGUI::Window *wnd = CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"button2");
wnd->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&MainMenu::GUICallBack, this));
And in callback-function differentiate between the events by their names:
Code: Select all
bool MainMenu::GUICallBack(const CEGUI::EventArgs& e)
{
const CEGUI::WindowEventArgs& we = (const CEGUI::WindowEventArgs&)e;
std::string win_name = we.window->getName().c_str();
if(win_name.compare("button1") == 0) {
//handle button 1
}
else if(win_name.compare("button2") == 0) {
//handle button 2
}
}
kind regards
Martin Bang Andersen