Global Event Set

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
ritz
Quite a regular
Quite a regular
Posts: 49
Joined: Wed Jan 12, 2005 12:06

Global Event Set

Postby ritz » Wed May 04, 2005 09:55

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

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Re: Global Event Set

Postby lindquist » Thu May 05, 2005 12:10

when using the global eventset, you must "prefix" the event string with the widgets event namespace fx:

"FrameWindow/CloseClicked"


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 2 guests