SFML community forums
Help => Window => Topic started by: Gregory on December 11, 2009, 02:36:34 pm
-
how do i get a char or pointer to char of the last key pressed in ACSII, to make a text box?
-
You must catch the sf::Event::TextEntered event, which gives you the character in event.Text.Unicode. This is a UTF-32 character, but you can safely cast it to a char if it is < 128 (ie. in the ASCII range).
-
Sorry, but i'm inexperient, how do i make this?
-
Did you first read the tutorials, to learn how to write a game and event loop? What problems do you get exactly?
-
I'm make a very good online game, the problem is not this, i'm brazilian and my english is not very good, can you write the code for i make that you speaked?
-
I think he just wanna use the TextEntered event
You've gotta use sf::Event::TextEntered.
Then use Event.Text.Unicode to add the new letter entered to your string
-
Well, no. I prefer taking time to explain what you don't understand, rather than providing you with a source code that you can copy-and-paste directly in your code.
So, what did you try? What code do you already have? What don't you understand?
-
I think he just wanna use the TextEntered event
You've gotta use sf::Event::TextEntered.
Then use Event.Text.Unicode to add the new letter entered to your string
This is exactly what I first said...
-
Sorry didn't see :lol:
-
Gregory what about posting your code so we can see where you're stuck in order to help you out ?
-
if (myevent.Type == sf::Event::KeyPressed and state == 0 and tempo_novo != -1 and myevent.Key.Code == sf::Key::A) {
if (myevent.Key.Code == sf::Key::BackSlash) {
pos_cur--;
nome_digit[pos_cur+1] = '\0';
}
else {
nome_digit[pos_cur] = myevent.Key.Code;
nome_digit[pos_cur+1] = '\0';
nome_str = nome_digit;
record_name[tempo_novo] = nome_str;
if (pos_cur < 13) {
pos_cur++;
}
}
}
-
You must forget sf::Event::KeyPressed and use sf::Event::TextEntered.