That was fast! And no problem about the code - that's the least I could do as payment for you making SFML. Great deal, I think!
Unfortunately, I may have found another one, also related to GetInput().
A wiser man than before, I am including a minimal example:/***********************************************************
* Possible Window.GetInput() bug No. 2 Minimal example
***********************************************************/
///////////////////////////////////////////////////////////
// Headers
///////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
///////////////////////////////////////////////////////////
// Application entry point
///////////////////////////////////////////////////////////
int main()
{
/////////////////////////////
// Setup variables
/////////////////////////////
sf::RenderWindow window(sf::VideoMode(1024, 768, 32), "Possible Window.GetInput() bug No. 2 Minimal example");
bool mouseClicked = false;
sf::String output;
/////////////////////////////
// Main loop
/////////////////////////////
while(window.IsOpened())
{
/////////////////////////
// Handle events
/////////////////////////
sf::Event event;
while(window.GetEvent(event))
{
if(event.Type == sf::Event::Closed)
window.Close();
else if(event.Type == sf::Event::MouseButtonPressed)
{
if(event.MouseButton.Button == sf::Mouse::Left)
mouseClicked = true;
else if(event.MouseButton.Button == sf::Mouse::Right)
{
mouseClicked = false;
output.SetText("");
}
}
else if(event.Type == sf::Event::MouseMoved)
{
if(window.GetInput().IsMouseButtonDown(sf::Mouse::Left) && mouseClicked == false)
output.SetText("Mouse was down before it was clicked!");
}
}
/////////////////////////
// Draw
/////////////////////////
window.Clear();
window.Draw(output);
window.Display();
}
return EXIT_SUCCESS;
}
With this program, if I click the left mouse button, while moving the mouse around, window.GetInput().IsMouseButtonDown(sf::Mouse::Left) evaluates to true before I get the chance to handle the MouseButtonPressed event with Window.GetEvent().
I can see how this could be interpreted as a "feature", but intuitively, shouldn't IsMouseButtonDown() only evaluate true after the MouseButtonPressed event has happened? Otherwise, IsMouseButtonDown() can't really be used as a true substitute manually handling "is down" states.
Oh, and in the program, you can use the right mouse button to reset.