SFML community forums
Help => System => Topic started by: Fox3 on June 13, 2010, 11:56:28 pm
-
So I made this little textbox here, and when I press backspace it should delete the last character. But it only happens once, like if I press it again nothing happens. The text stays the same.
Here is the code:
while(newstagewnd.GetEvent(event))
{
if(event.Type == sf::Event::KeyPressed and event.Key.Code == sf::Key::Back)
{
if(titlein.value.size()>0)
{
titlein.value.resize(titlein.value.size()-1);
}
}
if(event.Type == sf::Event::TextEntered)
{
if(event.Text.Unicode < 256)
{
titlein.addinput(static_cast<char>(event.Text.Unicode));
}
}
if(event.Type == sf::Event::Closed)
{
newstagewnd.Close();
}
}
Any help on this?
-
Backspace is a valid character in the Unicode standard, thus it also produces a TextEntered event that you must filter out :)