Final problem!

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
POLSKASH
Not too shy to talk
Not too shy to talk
Posts: 44
Joined: Mon Jun 20, 2005 14:45

Final problem!

Postby POLSKASH » Fri Jul 15, 2005 02:53

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?

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Re: Final problem!

Postby lindquist » Fri Jul 15, 2005 12:26

please post your guiManager->injectKeyPress function

User avatar
POLSKASH
Not too shy to talk
Not too shy to talk
Posts: 44
Joined: Mon Jun 20, 2005 14:45

Re: Final problem!

Postby POLSKASH » Fri Jul 15, 2005 16:09

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.

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Re: Final problem!

Postby lindquist » Fri Jul 15, 2005 16:18

I can't see the code for that... Just knowing it's there is not alot of info...

User avatar
POLSKASH
Not too shy to talk
Not too shy to talk
Posts: 44
Joined: Mon Jun 20, 2005 14:45

Re: Final problem!

Postby POLSKASH » Fri Jul 15, 2005 19:57

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);
}

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Re: Final problem!

Postby lindquist » Fri Jul 15, 2005 20:13

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;
}


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 5 guests