I'm in the process of trying to squeeze all the CEGUI functionality I need in my project into a dll that could easily be swapped out should a better dll be made in the future. One of the problems I'm having is working around CEGUI's event system.
Right now my thoughts are to write an event manager and map CEGUI's event handler to a central function of my own event handler. The problem I'm running into is determining what event was called when that function is executed. There is a possibility of a single window or component issuing more than one type of event, so its imparative for me to know what event is called in order for my event handler to make the appropriate function call.
Is there any way for me to determine what event was called from within this central method? If not, how might I tap into CEGUI's event systems backend to implement the functionality I require?
Thanks a lot for your help.
Central Event Handler
Moderators: CEGUI MVP, CEGUI Team
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Central Event Handler
Probably the only thing you could do is modify the base EventArgs to include an 'EventType' field which holds some id code / enum value which indicates the event, and then modify all the placees that fire an event to set this field appropriately.
I have a major aversion to these huge monolithic event handlers (ala Win32 "WindowsProc"), which is why there is currently, nor will there ever be, such an id field in the 'official' version of EventArgs, though if you need this then obviously you're free to implement that as described above
CE.
I have a major aversion to these huge monolithic event handlers (ala Win32 "WindowsProc"), which is why there is currently, nor will there ever be, such an id field in the 'official' version of EventArgs, though if you need this then obviously you're free to implement that as described above
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Central Event Handler
I was afraid you were going to say that :-/ The only reason I didn't like that option is that every time you come out with a new version I wanted to implement into the system I'm going to have to go into the source and change that bit of code.
But on a side note, that extra field could be used for uses other than to create some huge event function. Maybe I'm crazy and I like pointing all the events for a single control to a single event handler. This would allow me to differentiate between events.
I can understand you not liking the wndproc, I came up with a way to get rid of that nasty switch statement myself when I was taking my GUI class . But I'm sure I'm not the only one to benefit if you were to add that extra field. I'm the kind of person that likes giving people options, even if I don't feel they are the best.
Well thanks for the reply, I've got some compiling to do
But on a side note, that extra field could be used for uses other than to create some huge event function. Maybe I'm crazy and I like pointing all the events for a single control to a single event handler. This would allow me to differentiate between events.
I can understand you not liking the wndproc, I came up with a way to get rid of that nasty switch statement myself when I was taking my GUI class . But I'm sure I'm not the only one to benefit if you were to add that extra field. I'm the kind of person that likes giving people options, even if I don't feel they are the best.
Well thanks for the reply, I've got some compiling to do
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Central Event Handler
To save editing CEGUI code, you could make use of some kind of proxy event hander (so you'd have one of those for each event type you're going to handle), and in there you basically forward the event to your "mega-handler" routine along with an additional parameter to identify the event type. Still some work for you, but I think this has the potential to be slighly more maintainable and resistant to changes in CEGUI itself.
CE.
CE.
Return to “Modifications / Integrations / Customisations”
Who is online
Users browsing this forum: No registered users and 4 guests