SFML community forums
Help => Graphics => Topic started by: phraze on May 20, 2009, 11:25:55 am
-
Hey, im new to SFML, and pretty new to c++.
Im currently writing on the ingame console for a game,
and im having problems figuring out how to make the text-input part.
Do i need to write some type of keymapsystem ?
Any help or maybe links to tutorials would be highly appreciated!
-
Use TextEntered event ( ? ) http://www.sfml-dev.org/tutorials/1.5/window-events.php
-
Use TextEntered event ( ? ) http://www.sfml-dev.org/tutorials/1.5/window-events.php
Okay, im going crazy about this.
How do you get exactly what is entered by text-entered ?
-
From the tutorial:
sf::Event Event;
while (App.GetEvent(Event))
{
// Window closed
if (Event.Type == sf::Event::Closed)
Running = false;
// Escape key pressed
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
Running = false;
}
-
Wrong. Keypress events are for key press, not for text input.
sf::Event Event;
while (App.GetEvent(Event))
{
// Character entered
if (Event.Type == sf::Event::TextEntered)
{
sf::Uint32 unicode = Event.Text.Unicode;
...
}
}
What to do then with the unicode character depends on what encoding you use. If you're using ASCII, you can just cast it to char if its value is less than 128.