blAaarg wrote:Also note that
OnEvent ( const SEvent & event ) sends a
const event parameter so you can't use, say,
to change the event before passing it on to the next event handler.
i'm all pretty new to this (i'm originally a pascal programmer) however thanks to
this thread i've found something that could be useful. However it seems like i'm having some problems with the const declarations.
what i'm running into is this:
i can printf the variables, but i cant pass them to another function...
Code: Select all
virtual bool OnEvent(const SEvent& event)
{
if (event.EventType == EET_USER_EVENT)
{
const tCommandEvent& custom = (const tCommandEvent&)event;
printf ("%s",custom.GetCommand()); <-- this works
// Context.scenemanager->ProcessCommand(custom.GetCommand(),custom.GetParameter()); <- this gives me an error
}
return false;
}
the declaration of processcommand:
Code: Select all
void SceneManager::ProcessCommand(core::stringc _COMMAND, core::stringc _PARAMETER)
{
printf("[COMMAND]: %s PARAM: %s",_COMMAND,_PARAMETER);
}
and this is the CustomEvents.h file
Code: Select all
#ifndef CUSTOMEVENTS_H
#define CUSTOMEVENTS_H
#include "irrlicht.h"
using namespace irr;
class tCommandEvent : public SEvent
{
struct CommandData
{
core::stringc COMMAND;
core::stringc PARAMETER;
};
public:
tCommandEvent() { EventType = EET_USER_EVENT; }
// no destructor needed, lifetime of s is longer than the instance
// that uses it.
void SetCommand(core::stringc _COMMAND)
{
MyData.COMMAND = _COMMAND;
}
void SetParameter(core::stringc _PARAM)
{
MyData.PARAMETER = _PARAM;
}
core::stringc GetCommand() const
{
return MyData.COMMAND;
}
core::stringc GetParameter() const
{
return MyData.PARAMETER;
}
private:
CommandData MyData;
};
#endif //CUSTOMEVENTS_H