SFML community forums

Help => General => Topic started by: pickumater on August 20, 2013, 12:25:21 pm

Title: Text input
Post by: pickumater 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 : )
Title: Re: Text input
Post by: G. 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 (http://www.sfml-dev.org/documentation/2.1/classsf_1_1Window.php#aef9f2b14c10ecba8a8df95dd51c5bb73).
Title: Re: Text input
Post by: Laurent on August 20, 2013, 12:42:08 pm
This piece of code is inside the event loop, right?
Title: Re: Text input
Post by: pickumater on August 20, 2013, 01:02:25 pm
Thank you Laurent, I got it fixed, that code  wasn't in the event loop. : )