Do you have a function or know of simple code that converts std::strings (which are the same as Ogre::Strings in my case) to the UTFString format that is required for TextBox's addCharacter()? I am using OIS, and checking all unbuffered characters before writing string characters from them, and adding them to my textbox. Have you favoured UTFString instead of String because String didn't support enough characters?
Code to convert a single character would be fine.
OK, well, I've tried using this code to convert a character from std::string to UTFString:
It may have worked -- I'm not sure. I can now add characters, and the cursor moves along the textbox as I do -- but the characters are not visible. The textbox has the standard GUI background material(s). I also tried doing this beforehand to make sure it wasn't a text color issue:
No dice. I know that this may not matter in the next version of QuickGUI anyway, but if you know what's up... : )
Turns out I just needed to play a little more. The working code is:
OK, so now I'm trying to send QuickGUI a backspace! I tried \b as my std::string (which should compile to the backspace escape ascii key...possibly), but that just sort of mini-tabbed forward in my textbox after conversion to utf character.
I looked at
but couldn't see anything helpful.
Being able to get the character in ASCII from OIS without translating myself (as I am now) might solve the problem. Right now I'm doing:
There must be a way to do this from a keycode in OIS without manual translation -- right?
This worked OK from the OIS side, but QuickGUI printed Bs. This is when I remembered that I should be using a QuickGUI character delete function for this anyway
It's rather particular to my situation, but in case anyone finds this useful...
std::string newChar = mInputMgr->checkAllCharsNew(); // custom function added to InputManager, returns only characters which are down for the first time, i.e. have not been held down; returns them in string form
if (newChar == "BACK" || (mInputMgr->checkKeyDown(OIS::KC_BACK) && lastBackkey < timeCurrentFrame-70))
lastBackkey = timeCurrentFrame;
else if (newChar == "DEL" || (mInputMgr->checkKeyDown(OIS::KC_DELETE) && lastDelkey < timeCurrentFrame-70))
lastDelkey = timeCurrentFrame;
else if (newChar == "RIGHT" || (mInputMgr->checkKeyDown(OIS::KC_RIGHT) && lastRightkey < timeCurrentFrame-70))
lastRightkey = timeCurrentFrame;
if (loadSaveTxt->getTextWidget()->getCursorIndex() < loadSaveTxt->getText().length())
else if (newChar == "LEFT" || (mInputMgr->checkKeyDown(OIS::KC_LEFT) && lastLeftkey < timeCurrentFrame-70))
lastLeftkey = timeCurrentFrame;
if (loadSaveTxt->getTextWidget()->getCursorIndex() > 0)
else if (newChar != "")