31
Window / Getting Integer Input
« on: August 15, 2010, 11:21:55 am »
I have a program that displays a map and I need it to allow the user to input coordinates for that map. I'm trying to do the text input, but I've run into problems.
- 1) The text doesn't display on the screen as you input
2) It doesn't display on the screen after you input it either
3) I doubt it's even working
Code: [Select]
bool PressA = false;
std::string XCoord;
sf::String text;
// Press A : Add coords
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::A))
{
PressA = true;
// In event loop...
if (Event.Type == sf::Event::TextEntered)
{
// Handle ASCII characters only
if (Event.Text.Unicode < 128)
{
XCoord += static_cast<int>(Event.Text.Unicode);
text.SetText(XCoord);
}
}
}
if (PressA == true)
App.Draw(text);