So I just started developing games using SFML, and I've got a major problem. I have my main loop set up thusly:
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
if (event.type == sf::Event::LostFocus)
paused = true;
if (event.type == sf::Event::GainedFocus)
paused = false;
}
if(paused)
continue;
ship.resetDirections();
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
{
ship.direction[3] = true;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
{
ship.direction[1] = true;
}
ship.updatePosition();
window.clear();
window.draw(ship);
window.display();
}
Now, you'll notice, in the polling loop, I have a pausing thing going on. Losing focus pauses the game, gaining focus resumes the game. Pretty basic pausing system for now (I'll make a pause menu eventually). But, when I click inside the window frame (anywhere but the title bar, or the outline around the black that the background currently is), the window isn't actually getting focus. It doesn't, unless I actually go and click the window frame, or click the program's icon on my start bar (Windows 7). I'm using VS2012, and have it going through the System package to maintain compatibility.