Hi!
While reading the code, I see that the unsuscribe method is private, so I would like to know which is the right way to unsuscribe an event without destroying the sender or receiver.
Thanks!
About events.
Moderators: CEGUI MVP, CEGUI Team
About events.
May the Force be with you!
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
About events.
When you subscribe to an event you get returned a CEGUI::Event::Connection object. This can be used to disconnect / unsubscribe by calling the disconnect() method. There's also a CEGUI::Event::ScopedConnection class that will auto-disconnect when the ScopedConnection object goes out of scope.
HTH
CE.
HTH
CE.
About events.
Thanks for the quick reply!
This is the scenario:
I want to have a handle function that will subscribe to all the event of one type of gui element. Let´s say it is a PushButton for simplicity and the EventClicked event.
So if I suscribe all the instances of pushbutton with this unique function I need to keep a copy of each connection object in order to unsuscribe them?
Is there a way to avoid having that reference?, like requesting it or something?
Thanks!
This is the scenario:
I want to have a handle function that will subscribe to all the event of one type of gui element. Let´s say it is a PushButton for simplicity and the EventClicked event.
So if I suscribe all the instances of pushbutton with this unique function I need to keep a copy of each connection object in order to unsuscribe them?
Is there a way to avoid having that reference?, like requesting it or something?
Thanks!
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
About events.
Yeah, you pretty much need to track those Connection objects The internals of it are that each subscription to an event creates a new internal 'subscriber' object; the only external way to control that is via the returned Connection.
Since you're obviously after something a little more advanced, you might consider sub-classing the types you're targetting and setting up something custom built via the Windows on<event> handlers (which you could code in such a way to enable quick and easy connections right across all instances of the type). If you register a factory for your subclasses and alias them to the 'normal' type (for example Taharez/Button), then whenever a widget of that type is requested, they'd actually get your sub-class.
Not sure if that's explained very well, but I hope so
CE.
Since you're obviously after something a little more advanced, you might consider sub-classing the types you're targetting and setting up something custom built via the Windows on<event> handlers (which you could code in such a way to enable quick and easy connections right across all instances of the type). If you register a factory for your subclasses and alias them to the 'normal' type (for example Taharez/Button), then whenever a widget of that type is requested, they'd actually get your sub-class.
Not sure if that's explained very well, but I hope so
CE.
About events.
Ok, but why is the event unsubscribe private?
Should not be public and have a unsubscribeEvent call?
That will prevent the storing of the connection object, no?
Should not be public and have a unsubscribeEvent call?
That will prevent the storing of the connection object, no?
May the Force be with you!
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
About events.
The unsubscribe method is an implementation method, I'm not entirely sure if it works the way you want it to
Have you tried making it public and running a few tests to see if it works okay? If it does, let me know, and I'll run a few tests of my own and will consider promoting the method into the public interface.
CE.
Have you tried making it public and running a few tests to see if it works okay? If it does, let me know, and I'll run a few tests of my own and will consider promoting the method into the public interface.
CE.
About events.
Nope, I was asking in order to get the designer view before getting my hand dirty.
I will give it a a try and tell you how it goes.
I will give it a a try and tell you how it goes.
May the Force be with you!
Return to “Modifications / Integrations / Customisations”
Who is online
Users browsing this forum: No registered users and 4 guests