Hello All,
I am trying to implement Timer class in my widget. Every time timer gets fired I want to send an event to my window.
I have tried using GlobalEventSet for that.
Here is the code
#include "CEGUITimer.h"
#include "CEGUIBase.h"
#include "CEGUIGlobalEventSet.h"
namespace CEGUI
{
const utf8 CEGUITimer::EventTimerFired[] = "TimerFired";
CEGUITimer::CEGUITimer(Ogre::Root* p, long interval)
{
Ogre::Root::getSingleton().getTimer()->getMilliseconds();
p->addFrameListener(this);
setInterval( interval );
GlobalEventSet::getSingleton().addEvent(EventTimerFired);
}
CEGUITimer::~CEGUITimer()
{
mRoot->removeFrameListener(this);
}
bool CEGUITimer::frameStarted(const Ogre::FrameEvent& e)
{
if(mCounter > 0)
mCounter -= e.timeSinceLastFrame;
else
{
mCounter = mInterval;
onNotifyTimedEvent();
}
return true;
}
void CEGUITimer::setInterval(long interval)
{
mInterval = interval;
if( mCounter == 0)
mCounter = interval;
}
void CEGUITimer::onNotifyTimedEvent()
{
EventArgs args;
GlobalEventSet::getSingleton().fireEvent(EventTimerFired, args);
}
}
My timer is working fine.
Here is the code which i am using for subscription
Ogre::Root * root = NULL;
root = Ogre::Root::getSingletonPtr();
if (root == NULL)
return false;
d_timer = new CEGUITimer(root, duration);
if (d_timer != NULL)
{
GlobalEventSet::getSingleton().subscribeEvent(CEGUITimer::EventTimerFired,
Event::Subscriber(&HTMLViewer::onTimerFired, this));
return true;
}
The issue is in receiving the event. I am not able to receive the event.
I tried debugging fireevent code, what i could get is event is not getting fired.
Can any body please tell me where i am going wrong.
Thanks,
Ritz
Global Event Set
Moderators: CEGUI MVP, CEGUI Team
- lindquist
- CEGUI Team (Retired)
- Posts: 770
- Joined: Mon Jan 24, 2005 21:20
- Location: Copenhagen, Denmark
Re: Global Event Set
when using the global eventset, you must "prefix" the event string with the widgets event namespace fx:
"FrameWindow/CloseClicked"
"FrameWindow/CloseClicked"
Return to “Modifications / Integrations / Customisations”
Who is online
Users browsing this forum: No registered users and 8 guests