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

Author Topic: Text input  (Read 1560 times)

0 Members and 1 Guest are viewing this topic.

pickumater

  • Newbie
  • *
  • Posts: 4
    • View Profile
Text input
« on: August 20, 2013, 12:25:21 pm »
Hello, I'm having a problem with inputting text. I saw on the forums that this is one way
of doing it:

 if (event.type == sf::Event::TextEntered){
                                         if(StringPort.length()<5){
                                                 StringPort+=static_cast<char>(event.text.unicode);Sleep(150);}
                          VnesenPort.setString(StringPort);
                                                   if(event.text.unicode==8)
                                                        StringPort.erase();
 

But that doesn't work so good, because whenever I type something in, the program types it too fast, so I'm using the Sleep function, but there is obviously a better way. Please help me out : )

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Text input
« Reply #1 on: August 20, 2013, 12:39:27 pm »
Is it as fast as when typing in a text area like this one on the forum?
If yes and if that doesn't suit you maybe you want to disable key repeat.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Text input
« Reply #2 on: August 20, 2013, 12:42:08 pm »
This piece of code is inside the event loop, right?
Laurent Gomila - SFML developer

pickumater

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Text input
« Reply #3 on: August 20, 2013, 01:02:25 pm »
Thank you Laurent, I got it fixed, that code  wasn't in the event loop. : )

 

anything