Page 1 of 1

Is it possible to use Unbuffered input with CEGUI?

Posted: Fri Aug 15, 2008 17:02
by majc
Im using unbuffered input.
When i click in my exit button nothing happens.
This is my code:

cGUIInterface.cpp

bool cGUIInterface::handleQuit(const CEGUI::EventArgs& e)
{
vendorWindow->hide();
return true;
}

void cGUIInterface::vendorMenu()
{
mGUISystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
if (!loadGUILayout)
{
loadGUILayout = CEGUI::WindowManager::getSingleton().loadWindowLayout((CEGUI::utf8*)"DFgui.layout");
mGUISystem->setGUISheet(loadGUILayout);
}
loadGUILayout->hide();
vendorWindow = winMgr->getWindow((CEGUI::utf8*)"MainWindow");
vendorWindow->show();
winMgr->getWindow((CEGUI::utf8*)"QuitButton")->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&cGUIInterface::handleQuit, this));
}

and this is my OgreNewtFrameListener code:

Code: Select all

if( ms.buttonDown( MB_Left ) )
   {
      if (timer2 <= 0.0)
      {
         if(FPSmode)
         {
            Ray ray = mBulletGraph->fireCameraRay(0.5,0.5);
            mBullet->update(evt.timeSinceLastFrame, mPlayerCollision, 1000, 5000, 10, ray.getOrigin(), ray.getDirection(), true, mWorld);
            timer2 = 0.5;
         }
         else
         {
            CEGUI::Point mousePos = CEGUI::MouseCursor::getSingleton().getPosition();
            CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);
            Ray ray = mBulletGraph->fireCameraRay(mousePos.d_x/float(ms.width), mousePos.d_y/float(ms.height));
            mBullet->update(evt.timeSinceLastFrame, mPlayerCollision, 1000, 5000, 10, ray.getOrigin(), ray.getDirection(), false, mWorld);
            timer2 = 0.5;
         }
      }
   }


but when i click quit never enters in the handlequit function :s
Thanks in advance!

Posted: Fri Aug 15, 2008 18:22
by malachy1681
I don't see in your code where you are injecting a mouse button up event. Since a clicked event is not fired until a mouse down/up combo is received, the clicked event handler will never get called.

Posted: Fri Aug 15, 2008 19:47
by Jamarr
As malachy says, you need to inject input into CEGUI. It does not "automagically" handle input. I suppose you haven't read this tutorial yet: http://www.cegui.org.uk/wiki/index.php/The_Beginner_Guide_to_Injecting_Inputs

In case you missed any other tutorials:
http://www.cegui.org.uk/wiki/index.php/Tutorials

Posted: Fri Aug 15, 2008 22:03
by majc
I read it but i thought with unbuffered input its behavior was different but i solved the problem using buffered input and for what you said i can only use buffered input with cegui.
Thanks guys.

Posted: Sat Aug 16, 2008 06:36
by malachy1681
It is possible to detect a mouse key up event in unbuffered mode, but it would take more code than simply using buffered. Unless you have some real need to catch GUI input in unbuffered mode, there shouldn't be a reason to go to the trouble of implementing it.

Posted: Sat Aug 16, 2008 10:21
by majc
Yes you right :) Everything is working fine now :)