Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Backspace problem  (Read 2559 times)

0 Members and 1 Guest are viewing this topic.

Fox3

  • Newbie
  • *
  • Posts: 10
    • View Profile
Backspace problem
« 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:
Code: [Select]
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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32451
    • View Profile
    • SFML's website
    • Email
Backspace problem
« Reply #1 on: June 14, 2010, 12:13:00 am »
Backspace is a valid character in the Unicode standard, thus it also produces a TextEntered event that you must filter out :)
Laurent Gomila - SFML developer

 

anything