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

Author Topic: Coding a text box  (Read 1659 times)

0 Members and 1 Guest are viewing this topic.

BeautiCode

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Coding a text box
« on: December 13, 2014, 08:34:09 am »
Hey everyone,
I'd love it if someone could help me develop a text box.
What i'm currently doing is using sf::isKeyPressed() and using sf::Clock. I append the key to a string every time a  key press is detected but not allow it to happen unless a certain amount of milliseconds has passed between the previous key press detection.
But things aren't working out as expected. Sometimes too many keys are pressed at once or sometimes none are detected at all. I need it to function like a normal keyboard.
I'm not doing this in my main class either i'm doing it in another class in the background while my normal event loop is running.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: Coding a text box
« Reply #1 on: December 13, 2014, 10:08:09 am »
Use the TextEntered event. The keyboard state function is not suitable for that kind of thing.

http://www.sfml-dev.org/tutorials/2.1/window-events.php#the-textentered-event
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

BeautiCode

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Coding a text box
« Reply #2 on: December 14, 2014, 03:58:17 am »
Thank you I got it, thanks. :)