[Solved] Check if CEGUI has processed input

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

gams
Not too shy to talk
Not too shy to talk
Posts: 39
Joined: Sun May 24, 2015 13:23

[Solved] Check if CEGUI has processed input

Postby gams » Fri Sep 18, 2015 07:01

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 ----
Last edited by gams on Fri Sep 18, 2015 11:35, edited 1 time in total.

lucebac
Just can't stay away
Just can't stay away
Posts: 193
Joined: Sat May 24, 2014 21:55

Re: Check if CEGUI has processed input

Postby lucebac » Fri Sep 18, 2015 09:23

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

gams
Not too shy to talk
Not too shy to talk
Posts: 39
Joined: Sun May 24, 2015 13:23

Re: Check if CEGUI has processed input

Postby gams » Fri Sep 18, 2015 10:30

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.

lucebac
Just can't stay away
Just can't stay away
Posts: 193
Joined: Sat May 24, 2014 21:55

Re: Check if CEGUI has processed input

Postby lucebac » Fri Sep 18, 2015 10:34

Check whether inject*() returns true or false:
http://static.cegui.org.uk/docs/0.8.4/c ... 3d9335ff14

gams
Not too shy to talk
Not too shy to talk
Posts: 39
Joined: Sun May 24, 2015 13:23

Re: Check if CEGUI has processed input

Postby gams » Fri Sep 18, 2015 11:02

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;                     

lucebac
Just can't stay away
Just can't stay away
Posts: 193
Joined: Sat May 24, 2014 21:55

Re: Check if CEGUI has processed input

Postby lucebac » Fri Sep 18, 2015 11:06

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.

gams
Not too shy to talk
Not too shy to talk
Posts: 39
Joined: Sun May 24, 2015 13:23

Re: Check if CEGUI has processed input

Postby gams » Fri Sep 18, 2015 11:35

Nevermind I had to dig deeper to put few subscribeEvent functions in order. And now it works.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 5 guests