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

Author Topic: String keyboard input  (Read 3307 times)

0 Members and 1 Guest are viewing this topic.

Stupebrett

  • Newbie
  • *
  • Posts: 15
    • View Profile
String keyboard input
« on: April 22, 2011, 06:51:43 pm »
Is there a way to input a string from the keyboard from a window, for example; "hello", like 'cin' in the standard library?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
String keyboard input
« Reply #1 on: April 22, 2011, 07:24:16 pm »
You can use the sf::TextEntered event.
Laurent Gomila - SFML developer

Stupebrett

  • Newbie
  • *
  • Posts: 15
    • View Profile
String keyboard input
« Reply #2 on: April 22, 2011, 09:02:46 pm »
Thanks! Is there a way to directly assign a varible through keyboard input?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
String keyboard input
« Reply #3 on: April 22, 2011, 09:05:21 pm »
What do you mean?
Laurent Gomila - SFML developer

Stupebrett

  • Newbie
  • *
  • Posts: 15
    • View Profile
String keyboard input
« Reply #4 on: April 22, 2011, 09:44:12 pm »
Like:
Code: [Select]
int number;
cin >> number;

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
String keyboard input
« Reply #5 on: April 22, 2011, 10:34:06 pm »
No, the TextEntered event will only give you the characters that are typed (one by one), then it's up to you to store/convert them.
Laurent Gomila - SFML developer