Hello.
How can I set the same event-function for all Button? I want to play a sound when whatever button is pushed.
Thanks.
for each Button
{
button->subscribeEvent(PushButton::EventMouseClick, Event::Subscriber(&MyClass::playSound, this));
}
Same event to all Button element. [solved]
Moderators: CEGUI MVP, CEGUI Team
Same event to all Button element. [solved]
Last edited by Toge on Fri Mar 06, 2009 06:38, edited 2 times in total.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Hi,
There is a global event set that you can subscribe to. Each type of object that fires events also defines an event namespace, this is used in conjunction with the event name.
So, for the PushButton, you have CEGUI::PushButton::EventNamespace and CEGUI::PushButton::EventClicked. You use those like this (contrived example):
It's important to note that the namespace comes from the originating class. This means that for events such as EventMouseClick (which is different to PushButton::EventClicked) the namespace comes from the Window base class, so Window::EventNamespace.
If you don't want to use the 'EventNamespace' constants, you can use strings also, so you could just specify "PushButton/Clicked" which is shorter, but you may have to look up the namespace and event strings in the code
HTH
CE.
There is a global event set that you can subscribe to. Each type of object that fires events also defines an event namespace, this is used in conjunction with the event name.
So, for the PushButton, you have CEGUI::PushButton::EventNamespace and CEGUI::PushButton::EventClicked. You use those like this (contrived example):
Code: Select all
using namespace CEGUI;
String globalEventName( PushButton::EventNamespace + '/' + PushButton::EventClicked );
GlobalEventSet::getSingleton().subscribeEvent( globalEventName, myHandlerFunction );
It's important to note that the namespace comes from the originating class. This means that for events such as EventMouseClick (which is different to PushButton::EventClicked) the namespace comes from the Window base class, so Window::EventNamespace.
If you don't want to use the 'EventNamespace' constants, you can use strings also, so you could just specify "PushButton/Clicked" which is shorter, but you may have to look up the namespace and event strings in the code
HTH
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Who is online
Users browsing this forum: No registered users and 10 guests