Is it possible to know where an event came from other then by where it ends up?
I'm translating events to python so making a function for each event is kinda annoying.
[solved] Event originator identification
Moderators: CEGUI MVP, CEGUI Team
[solved] Event originator identification
Last edited by maglos on Sat Feb 10, 2007 21:44, edited 1 time in total.
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:
And in callback-function differentiate between the events by their names:
kind regards
Martin Bang Andersen
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
great
hey perfect thats exactly what I wanted thx, I knew this belonged in the beginner forum. I guess I assumed that if an event knew its originator it would be up in the core interfaces, I never thought to look at the WindowEventArgs implementation.
very helpful!
this is extremely helpful to know! i had been searching all over for a way to do exactly this. i knew it had to be possible.
i wiki'ed it here:
http://www.cegui.org.uk/wiki/index.php/ ... e_Callback
i wiki'ed it here:
http://www.cegui.org.uk/wiki/index.php/ ... e_Callback
Who is online
Users browsing this forum: No registered users and 28 guests


