Page 1 of 1

[Solved] Check if CEGUI has processed input

Posted: Fri Sep 18, 2015 07:01
by gams
Hi
How do you know the keyboard/mouse input has been processed by CEGUI so that you wont try to process it in your own code?

for example I have code like this to capture input:

Code: Select all

   SDL_Event event;

    while(SDL_PollEvent(&event))
    {
    case SDL_KEYDOWN:
       switch(event.key.keysym.sym)
       {
      case SDLK_LEFT: // Do something 
      break;
   }
    }
   


so how do you know CEGUI has processed the input so that I wont process it with SDL_pollevent ?

I dont want to catch the input my self when trying to edit an editbox in CEGUI.

thanks


CEGUI Log:

Code: Select all

18/09/2015 09:46:14 (Std)    ---- Version: 0.8.4 (Build: Aug  8 2015 Debug Microsoft Windows MSVC++ Great Scott! 32 bit) ----
18/09/2015 09:46:14 (Std)    ---- Renderer module is: CEGUI::OpenGLRenderer - Official OpenGL based 2nd generation renderer module.  TextureTarget support enabled via FBO extension. ----
18/09/2015 09:46:14 (Std)    ---- XML Parser module is: Unknown XML parser (vendor did not set the ID string!) ----
18/09/2015 09:46:14 (Std)    ---- Image Codec module is: SILLYImageCodec - Official SILLY based image codec ----
18/09/2015 09:46:14 (Std)    ---- Scripting module is: None ----

Re: Check if CEGUI has processed input

Posted: Fri Sep 18, 2015 09:23
by lucebac
CEGUI does not handle inputs as long as you don't tell CEGUI that a key and which key has been pressed. Look here for a code snippet:
https://bitbucket.org/lucebac/cegui/src ... L2.cpp-273

Re: Check if CEGUI has processed input

Posted: Fri Sep 18, 2015 10:30
by gams
lucebac wrote:CEGUI does not handle inputs as long as you don't tell CEGUI that a key and which key has been pressed. Look here for a code snippet:
https://bitbucket.org/lucebac/cegui/src ... L2.cpp-273


that is how I have it setup. but I think I need someway to tell when user is typing something to editbox in CEGUI so that the input wont be passed on.

Re: Check if CEGUI has processed input

Posted: Fri Sep 18, 2015 10:34
by lucebac
Check whether inject*() returns true or false:
http://static.cegui.org.uk/docs/0.8.4/c ... 3d9335ff14

Re: Check if CEGUI has processed input

Posted: Fri Sep 18, 2015 11:02
by gams
lucebac wrote:Check whether inject*() returns true or false:
http://static.cegui.org.uk/docs/0.8.4/c ... 3d9335ff14


putting break like this simply makes all input goto only to CEGUI

Code: Select all

if (CEGUI::System::getSingleton().getDefaultGUIContext().injectKeyDown((CEGUI::Key::Scan)event.key.keysym.scancode))
                        break;
                        
                        
if (CEGUI::System::getSingleton().getDefaultGUIContext().injectKeyUp((CEGUI::Key::Scan)event.key.keysym.scancode))
                        break;                     

Re: Check if CEGUI has processed input

Posted: Fri Sep 18, 2015 11:06
by lucebac
What are you doing?

Code: Select all

if (CEGUI::[...].injectKeyDown(key) == false)
{
    // there was no widget activated so the input has to be passed to your game (or whatever you are creating)
}
break;

This should do the trick.

Re: Check if CEGUI has processed input

Posted: Fri Sep 18, 2015 11:35
by gams
Nevermind I had to dig deeper to put few subscribeEvent functions in order. And now it works.