SFML community forums

Help => General => Topic started by: drakelord on June 30, 2009, 02:05:07 am

Title: [Solved] Issue with Keypress and sf::Key::Back
Post by: drakelord on June 30, 2009, 02:05:07 am
Ok, so, I have an editable text field that people can type into.  Text works fine.  The issue is the backspace key.

If someone presses it once, it works fine and does its job.  One character is removed from the string and properly displayed.  However, any other backspace presses after this do nothing until another displayable key is entered.  

Code: [Select]
if(GameEventsMenu.Key.Code == sf::Key::Back)
{
std::wstring tempstring = MenuSheets[2]->MenuEditTexts[SelectChoice].GetText();
if(tempstring.empty() == false)
tempstring.erase(tempstring.size() - 1);
MenuSheets[2]->MenuEditTexts[SelectChoice].SetText(tempstring.c_str());
}
Title: [Solved] Issue with Keypress and sf::Key::Back
Post by: Laurent on June 30, 2009, 07:51:57 am
You mean that you don't receive the key event from SFML?
Title: [Solved] Issue with Keypress and sf::Key::Back
Post by: drakelord on June 30, 2009, 04:49:26 pm
Well, I just did a test.  I added code to the event that spawns a message box upon receiving the backspace key event.  The message box does spawn each time, meaning that the event is being received.  This means that for some reason, the string isn't updating properly.  Hmm.
Title: [Solved] Issue with Keypress and sf::Key::Back
Post by: drakelord on June 30, 2009, 07:21:28 pm
I found the problem.  After it removed the character, it was inserting an invisible character (unicode 8) representing backspace, that wasn't actually displaying.  Fixed.  Hurray.