1
Graphics / Re: TextEntered input repeats
« on: July 07, 2022, 02:37:30 am »
Great, that was the trouble. Thank you very much!!!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
while (window.isOpen())
{
//ReadInput
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
if (event.type == sf::Event::TextEntered)
{
player.insertName(static_cast<char>(event.text.unicode));
player.update();
}
...
void Player::update()
{
_playerText.setString(_playerInput);
}
void Jugadorxs::innsertName(int unicode)
{
if (unicode == 8) { //If backspace
if (textSize > 0)
_playerInput.erase(static_cast<size_t>(textSize) - 1, 1);
}
else if (unicode >= 32 && unicode <= 126) {
_playerInput += (char)unicode;
}
else if (unicode >= 192 && unicode <= 255) {
_playerInput += (char)unicode;
}
}