Page 1 of 1

Capitals in EditBox when pressing "shift"

Posted: Tue Aug 14, 2007 15:03
by Ralf/pdx
I use CEGUI 0.5.0b, Ogre 1.4.3 and OIS .

My source works fine for lower case characters, but if i press shift i don´t get capitals or even chars which need a pressed shift key.

Therefore i tried to give CEGUI a manual "shift" state so that every char is a shifted one, but even that didn´t work.

This is a part of my source:

Code: Select all

gui.system->injectKeyDown( CEGUI::Key::LeftShift );
// send current key state to GUI
gui.system->injectChar( static_cast<uint>( input.keyListener.keyChar ));
gui.system->injectKeyDown( static_cast<uint>( input.keyListener.keyCode1 ));


bool CKeyListener::keyPressed( const OIS::KeyEvent &arg )
{
   keyCode1 = arg.key;
   keyChar = arg.text;

   return true;
}


Any idea/help for me:?:

Posted: Tue Aug 21, 2007 14:18
by Ralf/pdx
I still have this problem. How can input capitals in an EditBox?

Really noboy here who can give me a hint?

Posted: Tue Aug 21, 2007 15:47
by Rackle
Check my post on the Ogre forum:

Code: Select all

bool CeguiGameState::keyPressed( const OIS::KeyEvent &arg )
{
   CEGUI::System::getSingleton().injectKeyDown( arg.key );
   CEGUI::utf32 utf = keycodeToUTF32(arg.key);
   if(utf)
      CEGUI::System::getSingleton().injectChar(utf);
   return true;
}

bool CeguiGameState::keyReleased( const OIS::KeyEvent &arg )
{
   CEGUI::System::getSingleton().injectKeyUp( arg.key );
   return true;
}


OIS now supports Unicode so the keycodeToUTF32() function is no longer necessary.


Found the better post still on the Ogre forum:

Rackle wrote:Found my code snippits, with the OIS bit based on Using OIS. My initialise() has a slight difference:

Code: Select all

// If possible create a buffered keyboard
if( mInputSystem->getNumberOfDevices(OIS::OISKeyboard) > 0 ) {
  mKeyboard = static_cast<OIS::Keyboard*>( mInputSystem->createInputObject( OIS::OISKeyboard, true ) );
  mKeyboard->setEventCallback( this );
  mKeyboard->setTextTranslation(OIS::Keyboard::Unicode);
}


The I modified Managing Game States with OGRE to create a Cegui-aware game state

Code: Select all

bool CeguiGameState::keyPressed( const OIS::KeyEvent &arg )
{
   bool injected = CEGUI::System::getSingleton().injectKeyDown( arg.key );
   CEGUI::utf32 utf = keycodeToUTF32(arg.key);
   if(utf)
      CEGUI::System::getSingleton().injectChar(utf);
   return injected;
}


where the keycodeToUTF32 function comes from DirectInput to CEGUI utf32 although OIS arg.text can now return Unicode text, if the setTextTranslation() is used when creating the keyboard.

Posted: Sun Jan 18, 2009 21:25
by Worgle
I dig out this post because I used the solution presented in it and that still doesn't work.

I have exactly the same problem (I can't have uppercase characters in an editbox).

Here's my code (corrected with this post) :

After buffered Keyboard creation :

Code: Select all

   // register itself
   _pBufferedMouse->setEventCallback((OIS::MouseListener *) this);
   _pBufferedKeyboard->setEventCallback((OIS::KeyListener *) this);
   _pBufferedKeyboard->setTextTranslation(OIS::Keyboard::Unicode);
   assert(_pBufferedKeyboard->getTextTranslation() == OIS::Keyboard::Unicode);


In my class CeguiMgr:

=> _guiSystem is the CEGUI::System class
=> CeguiMgr is a class which inherits from OIS listeners

Code: Select all

bool CeguiMgr::keyPressed(const OIS::KeyEvent &e) {
   bool injected = _guiSystem->injectKeyDown( e.key );

       _guiSystem->injectChar(e.text );

   return injected;
}

bool CeguiMgr::keyReleased(const OIS::KeyEvent &e) {
   return _guiSystem->injectKeyUp(e.key);
}



I also tried with the utf conversion function quoted in this code but it doesn't work.

If anyone have an idea...

Thanks for reading,

Worgle

Posted: Sun Jan 18, 2009 22:02
by CrazyEddie
Hi, and welcome :)

As far as character input goes, CEGUI will use whatever codepoints you tell it to - we do no key mapping what so ever, which is why you have to inject key up/down events and characters.

The status of the shift keys, as far as CEGUI is concerned when it comes to character input is irrelevant; we do not look at the shift key and decide whether the character should be upper case or lower case.

Another (probably unlikely) possibility is that the font you're using does not contain glyphs for the codepoints that you are injecting.

It might be useful to output the values of

Code: Select all

e.text

as you inject them to see if they correspond to what you think they should, because the issue definitely lies there.

HTH

CE.

Posted: Sun Jan 18, 2009 22:07
by Worgle
First, thanks for this very quick response.

I'm kind of stuck here because the Ogre's guys say that it's a CEGUI issue, and of course here you saiy that it must be a OIS issue. I'm going to try the OIS forum but they are going to say that it's a CEGUI issue...

Where I'm supposed to post then ? ^^

Here's my post on Ogre's forum :
http://www.ogre3d.org/forums/viewtopic. ... 6&p=324501

I'm going to print this e.text value and to post on OIS forum.

Thanks again.

Worgle

Posted: Mon Jan 19, 2009 02:14
by Worgle
Resolved !

In fact it was the

Code: Select all

Ogre::WindowEventUtilities::messagePump();

which was commented in my code (I do not use the startRendering function). Uncommented and it worked (almost) just fine. Almost because when I type "Backspace", the character ° appear as the last character is deleted. But I used a "isSpecialKey" function (which check if a key is a backspace or return) to solve the problem. If it is a special key, I do not inject the char.

Thanks again all.

I hope this post will help someone ( I whish all this input/cegui/ogre things to be more easy to find on the web :) ).

Worgle

Posted: Mon Jan 19, 2009 09:54
by CrazyEddie
Hi,

Glad you figured it out - and thanks for posting the resolution :)

CE