Page 1 of 1

[solved] Numeric keyboard in EditBoxes

Posted: Fri Oct 30, 2009 13:43
by djphilipe
Hi,
why don't work numeric keyboard in editboxes?
I want input num characters, but it doesn't work.
How I can write with num keyboard?

Thanks very much
Filip

Re: Numeric keyboard in EditBoxes

Posted: Fri Oct 30, 2009 19:39
by Jamarr
did you turn on Num Lock on your keyboard?

Re: Numeric keyboard in EditBoxes

Posted: Mon Nov 02, 2009 07:14
by djphilipe
Do you think I'm stupid? :)

Re: Numeric keyboard in EditBoxes

Posted: Mon Nov 02, 2009 08:50
by djphilipe
The problem is in OIS. If I press for example key '5' on numeric keyboard OIS return keyEvent.text=0. I had to set text hard.

Code: Select all

bool GIKeyboardListener::keyReleased(const OIS::KeyEvent &arg)
{
 unsigned int text = arg.text;
   
   switch (arg.key) {
      case OIS::KC_NUMPAD0: text = '0'; break;
      case OIS::KC_NUMPAD1: text = '1'; break;
      case OIS::KC_NUMPAD2: text = '2'; break;
      case OIS::KC_NUMPAD3: text = '3'; break;
      case OIS::KC_NUMPAD4: text = '4'; break;
      case OIS::KC_NUMPAD5: text = '5'; break;
      case OIS::KC_NUMPAD6: text = '6'; break;
      case OIS::KC_NUMPAD7: text = '7'; break;
      case OIS::KC_NUMPAD8: text = '8'; break;
      case OIS::KC_NUMPAD9: text = '9'; break;
      case OIS::KC_DECIMAL: text = '.'; break;
   }
     return   m_pGUISystem->injectKeyDown( arg.key ) || m_pGUISystem->injectChar( text );
}

Re: Numeric keyboard in EditBoxes

Posted: Mon Nov 02, 2009 19:31
by Jamarr
djphilipe wrote:Do you think I'm stupid? :)


lol! Sorry I just couldn't resist. :wink: I'm glad you got it worked out.

As the Injecting Inputs tutorial mentions, how you obtain the UTF32 value to inject is something that is dependant upon the input library and so is up to you to figure out.

Thanks for posting your solution, I'm sure it will be of use to others using OIS.