I am using Ogre 1.9.0 with CEGUI 0.8.4.
I am doing a really simple test where I am creating a button with CEGUI and I have a method called Move which should be triggered by EventClicked.
But I can't get the PushButton::EventClicked to work.
The animation of the button works when I click it but I can't get the event to set my method to true.
For reference I was using this link as a guide: http://cegui.org.uk/wiki/CEGUI_In_Practice_-_A_push_button
This is my code:
Code: Select all
//Init
CEGUI::OgreRenderer* renderer = &CEGUI::OgreRenderer::bootstrapSystem();
CEGUI::SchemeManager::getSingleton().createFromFile("TaharezLook.scheme");
CEGUI::PushButton *button = static_cast<CEGUI::PushButton*>(CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Button","PushButton"));
button->setPosition(CEGUI::UVector2(CEGUI::UDim(0.5,0),CEGUI::UDim(0.50,0)));
button->setSize(CEGUI::USize(CEGUI::UDim(0,150),CEGUI::UDim(0,100)));
button->setText("PushButton");
button->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&OgreFramework::Move, this));
CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(button);
//Input init
d_systemInputAggregator = new CEGUI::InputAggregator(
&CEGUI::System::getSingletonPtr()->getDefaultGUIContext());
d_systemInputAggregator->initialise();
//
void OgreFramework::mouseMoved(const MouseMotionEvent &arg)
{
d_systemInputAggregator->injectMousePosition(arg.x, arg.y);
}
void OgreFramework::mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id )
{
pressed = true;
d_systemInputAggregator->injectMouseButtonDown( CEGUI::LeftButton);
}
void OgreFramework::mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id )
{
pressed = false;
d_systemInputAggregator->injectMouseButtonUp( CEGUI::LeftButton);
}
bool OgreFramework::Move(const CEGUI::EventArgs &e)
{
move = true;
return true;
}
then in my loop I am checking the value of move but it always returns 0.
Thanks,
Alex