I've been reading about this for 4 hours both docs and threads here but I was not able to make this work properly . i am posting this as new topic again because the threads i went to i guess are dead. I just simply want to ask max of 8 character input and delete characters when backspace is pressed. somehow i got it working but:
- it deletes the last character, but it replaces it with the backspace character value " ".
question is: what should i do so that the backspace character value is not inserted on the string?
here is my code:
if (event.type == sf::Event::TextEntered)
{
if((event.text.unicode < 128)&& playerInput.getSize()< 8 )
{ playerInput.insert(playerInput.getSize(), event.text.unicode);
playerText.setString(playerInput);
}
}
if(event.type == sf::Event::KeyPressed)
{
if(event.key.code == sf::Keyboard::BackSpace)
{playerInput.erase(playerInput.getSize()-1,2);
playerText.setString(playerInput);}
}