how can i hanle events in the c++? ( i'm using OpenGL renderer and SDL)
i use this code but its generate a runtime error and i dont konw what is wrong?:
events.cpp:
Code: Select all
Events::Events()
{
CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
CEGUI::Window *w = wmgr.getWindow("btn1");
w->setText ("hi"); // it works correclty and btn1 text changed to hi
w->subscribeEvent(CEGUI::PushButton::EventClicked ,
CEGUI::Event::Subscriber(&Events::Btn_Clicked , this)); // run time error occur here
}
bool Events::Btn_Clicked(const CEGUI::EventArgs &e)
{
std::cout << "yes" << std::endl;
return true;
};
events.h:
Code: Select all
class Events
{
public:
Events();
~Events(){};
protected:
bool Btn_Clicked(const CEGUI::EventArgs& e);
};
creating btn routine:
Code: Select all
CEGUI::PushButton *btn = static_cast<CEGUI::PushButton*>(wmgr.createWindow("TaharezLook/Button","btn1") );
fWnd->addChildWindow(btn);
btn->setPosition(CEGUI::UVector2(cegui_reldim(0.35f), cegui_reldim( 0.8)));
btn->setSize(CEGUI::UVector2(cegui_reldim(0.3f), cegui_reldim( 0.1f)));
btn->setText("Apply");