Page 1 of 1

Final problem!

Posted: Fri Jul 15, 2005 02:53
by POLSKASH
This is it folks. My final problem with CEGUI. Everything is running strong, and I'll see if I can host my program somewhere so you guys can see my use of it :) Overall, I'm definitely pleased with the results from CEGUI.

My final quirk is with using the shift key to produce capital letters. Right now, my edit box solely produces capital letters. I can't type in a lower case letter. I'm using the same code I used for my backspace key which works great. Here's the right shift, the left shift is the same, except for the obvious changed like using Key::LeftShift instead of Key::RightShift:

Code: Select all

   if(guiManager->alreadyDown(DIK_RSHIFT))
   {
      if(KeyState(DIK_RSHIFT) == TRUE)
      {
         CEGUI::Key::Scan k;
         k = CEGUI::Key::RightShift;
         guiManager->injectKeyPress(k);
         guiManager->setDown(DIK_RSHIFT);
      }
      else
      {
         CEGUI::Key::Scan k;
         k = CEGUI::Key::RightShift;
         guiManager->injectKeyUp(k);
         guiManager->setUp(DIK_RSHIFT);
      }
   }
   else
   {
      if(KeyState(DIK_RSHIFT) == TRUE)
      {
         CEGUI::Key::Scan k;
         k = CEGUI::Key::RightShift;
         guiManager->injectKeyPress(k);
         guiManager->setDown(DIK_RSHIFT);
      }
   }


The strange part is that when I tap the left shift key, I get bullets in the edit box. Yes, bullets. When I tap the right shift key, I get 6s (sixes) LOL. I'm not sure what I'm doing wrong here. All I need to do is inject scan codes for up and downs right?

Re: Final problem!

Posted: Fri Jul 15, 2005 12:26
by lindquist
please post your guiManager->injectKeyPress function

Re: Final problem!

Posted: Fri Jul 15, 2005 16:09
by POLSKASH

Code: Select all

void cGUIManager::injectKeyPress(const CEGUI::Key::Scan key)
{
   CEGUI::System::getSingleton().injectKeyDown(key);
   //injectChar(static_cast<CEGUI::uint32>(key));
}


I had the inject Char line uncommented, so I'm guessing that's why I was getting bullets and sixes. However, I'm still not able to type in lowercase letters. My injectChar() call is in my windows message handler just so you know.

Re: Final problem!

Posted: Fri Jul 15, 2005 16:18
by lindquist
I can't see the code for that... Just knowing it's there is not alot of info...

Re: Final problem!

Posted: Fri Jul 15, 2005 19:57
by POLSKASH
Here ya go:

Code: Select all

LRESULT CALLBACK cWindowsClass::WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
   switch(uMsg)
   {
   case WM_DESTROY:
      PostQuitMessage(0);
      break;

   case WM_KEYDOWN:
      if(guiManager != 0)
         guiManager->injectChar(static_cast<CEGUI::utf32>(wParam));
      break;

   default:
      return DefWindowProc(hWnd, uMsg, wParam, lParam);
   }

   return 0;
}


And

Code: Select all

void cGUIManager::injectChar(const CEGUI::utf32 charCode)
{
   CEGUI::System::getSingleton().injectChar(charCode);
}

Re: Final problem!

Posted: Fri Jul 15, 2005 20:13
by lindquist
If you had just looked in cegui_mk2/Samples/Common/src/Win32AppHelper.cpp you would see that a working way to do it is:

Code: Select all

LRESULT CALLBACK cWindowsClass::WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
   switch(uMsg)
   {
   case WM_DESTROY:
      PostQuitMessage(0);
      break;

   case WM_CHAR: // < --------------------------------------- HERE
      if(guiManager != 0)
         guiManager->injectChar(static_cast<CEGUI::utf32>(wParam));
      break;

   default:
      return DefWindowProc(hWnd, uMsg, wParam, lParam);
   }

   return 0;
}