Page 1 of 1

[SOLVED] Space bar not adding spaces in an editbox.

Posted: Sat Mar 01, 2014 03:28
by Zodiaclawl
Hello. Thanks for all the help a few days ago to compile CEGUI. I've started to integrate it with Irrlicht and I've come a long way. But I have a small problem now. I'm using the sample layout called VanillaConsole.layout and I'm trying to implement the features now. The problem I'm having is that I can't put spaces in the edit box of the console layout. I can write just fine, and I can use backspace to delete text, but spaces don't work.

Like so:
Image

I have checked the key injections to see if there's a problem. Since I'm using Irrlicht I have to convert some of the key codes to CEGUI::Key::Scan codes. But I'm pretty sure I haven't done anything wrong.

Code: Select all

bool PEventReceiver::injectSpecialKeysToCEGUI(wchar_t key)
{

   switch(key)
   {

   case KEY_BACK:
      {
         CEGUISystem->getDefaultGUIContext().injectKeyDown(CEGUI::Key::Scan::Backspace); //This code makes it possible to delete the text. If I comment it out I can't delete the text.
         return true;
      }

   case KEY_SPACE:
      {
         printf("This code gets executed.\n"); //This gets printed in the console. So CEGUI::Key::Scan::Space gets injected into CEGUI.
         CEGUISystem->getDefaultGUIContext().injectKeyDown(CEGUI::Key::Scan::Space);
         return true;
      }

   default:
      return false;

   }

}


Is there something I need to do to be able to write spaces in the text box? I'm sorry for pestering you with questions, but I don't really understand how this works yet.

Thanks in advance.

Re: Space bar not adding spaces in an editbox.

Posted: Sat Mar 01, 2014 06:28
by Ident
Are you also doing injectChar(...) ?

Re: Space bar not adding spaces in an editbox.

Posted: Sat Mar 01, 2014 13:34
by Zodiaclawl
Ident wrote:Are you also doing injectChar(...) ?

Oh my god I'm stupid...

Code: Select all

   case KEY_SPACE:
      {
         CEGUISystem->getDefaultGUIContext().injectKeyDown(CEGUI::Key::Scan::Space);
         CEGUISystem->getDefaultGUIContext().injectChar(' ');
         return true;
      }


This fixed it :P