SFML community forums
Help => Window => Topic started by: dove96 on March 24, 2016, 05:04:07 am
-
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);}
}
-
Next time please either create a new thread from the start or keep the discussion in the already resurrected thread. And don't post on multiple threads.
Just because you don't get a reply within 2.5h (at 3 in the morning in Europe where most people are from), doesn't mean a thread is "dead" or that nobody will look at it. ;)
The forum has an unread posts function, so if a new posts gets written, it will be seen.
-
You can always ask questions as long as you invest some time in trying to solve by yourself.
But when you ask, uou shouldn't make three posts about the same problem. ;)