Okay! I'm going to sound like a total noob. Haha! I wasn't sure if this problem belonged on this forum or the normal C++ forum, so forgive me if this is in the wrong forum but here is my problem.
//DECLARATION
bool X = false;
bool Y = false;
std::string XCoord;
std::string YCoord;
sf::String Coord;
Coord.SetFont(TypeKnight);
Coord.Move(175,10);
sf::String TopLeft("Text Input: ________________");
TopLeft.SetFont(TypeKnight);
TopLeft.Move(10,10);
TopLeft.SetColor(sf::Color::White);
enum State { State0, State1, State2, State3 };
State myState = State0;
int counter = 0;
//EVENT LOOP
if (myState == State0 && (Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::A))
{
std::cout << "ONE" << std::endl;
myState = State1;
}
if (myState == State1 && (Event.Type == sf::Event::TextEntered))
{
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Return))
{
if (X == false)
X = true;
if (X == true && Y == false)
Y = true;
}
std::cout << "TWO" << std::endl;
if (X == false && counter < 5) {
if (Event.Text.Unicode > 47 && Event.Text.Unicode < 58)
{
std::cout << "THREE" << std::endl;
XCoord += static_cast<int>(Event.Text.Unicode);
Coord.SetText(XCoord);
std::cout << XCoord << std::endl;
}
++counter;
}
if (X == true && Y == false && counter < 5) {
if (Event.Text.Unicode > 47 && Event.Text.Unicode < 58)
{
std::cout << "FOUR" << std::endl;
YCoord += static_cast<int>(Event.Text.Unicode);
Coord.SetText(YCoord);
std::cout << YCoord << std::endl;
}
++counter;
}
}
//MAIN LOOP
App.Draw(Coord);
if (X == true)
App.Draw(Comma);
What is supposed to happen:
1) The user presses A to activate text input.
2) The user types in the X coordinate and it is displayed
3) The comma is displayed when the user hits enter.
4) The user types in the Y coordinate and it is displayed along side the X coordinate in this fashion: X , Y
5) When the user hits enter, both the X and the Y values are stored on a text file. I haven't put that in yet.
This isn't what happens, obviously...
What does happen though, it displays the X coordinate as I type it. Then if I reach 4 numbers in the coordinate, it doesn't display the comma even if I hit enter. However, if I hit enter when I have 1, 2, or 3 numbers the comma is displayed just fine. Afterwards, it doesn't let me type the Y coordinate and I don't know why.
Please don't say I haven't tried to fix this. I stayed up for 28 hours and never fixed this stupid problem. Then after sleeping I spent another 6 hours trying to fix it again. I know it's probably going to end up being something so stupid....
Thanks