Page 1 of 1
[SOLVED] How to retrieve window that generated an event?
Posted: Wed Feb 10, 2010 22:46
by Houdini
I would really like to have a group of windows call the same "onevent" function when a particular event occurs, but I need to be able to retrieve the "user data" associated with the window that generated the event.
Is this possible?
edit: I found the solution in the wiki!!
- Houdini
Re: [SOLVED] How to retrieve window that generated an event?
Posted: Thu Mar 04, 2010 09:44
by madeinsoviets
Sorry, i have a question of this kind - how to extract event type (CEGUI::PushButton::EventClicked for e.g.)?
Re: [SOLVED] How to retrieve window that generated an event?
Posted: Thu Mar 04, 2010 10:35
by CrazyEddie
Hi,
It's not possible to extract the event name from within the event handler. The original idea was that since you're subscribing the handler to the event, you already know what the event name is!? This was a decision I took on purpose to stop people producing huge monolithic event handlers containing huge if / else if / endif structures that test for which event it is. With some hindsight, perhaps it is not for me to dictate how users of the library structure there code - but for now this is the situation.
I'm prepared to consider adding a second argument to the event handler function prototype that holds a reference to the event name String. Off the top of my head I'm unsure if this can be done in a suitable fashion for the stable branch - so it may end up being a svn trunk / v0.8.x kind of an enhancement.
CE.
Re: [SOLVED] How to retrieve window that generated an event?
Posted: Thu Mar 04, 2010 13:33
by madeinsoviets
Thanks, i 'll try to think my architecture over..)