Compiler: MinGW
IDE: CodeBlocks 13.12
Platform: Win7, 64bit
Repeatability: Always
Any special compiler settings: None
Version of SFML being used: Using 2.1, grabbed from the official downloads page.
This is the bug: When calling
mouseCoord = sf::Mouse::getPosition(window)
and the mouse cursor enters a region around (37,n+) (n+ being any positive number) for what ever reason
event.key.code == sf::Keyboard::Escape
becomes true. I am not sure why and I simply don't have enough skill to find out why.
Putting
mouseCoord = sf::Mouse::getPosition(window)
after the even code loop still causes
event.key.code == sf::Keyboard::Escape
to register as true.
I've actually noticed that the results are different depending on the key used. A couple of keys I've tested are listed at the bottom.
Using the global version of getPosition() doesn't seem to reproduce the bug.
Image used. The red part is generally where the "problem area" is.
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
sf::Texture texture;
if(!texture.loadFromFile("test.png"))
{
return -1;
}
sf::Sprite image(texture);
sf::Vector2i mouseCoord(0,0);
while(window.isOpen())
{
mouseCoord = sf::Mouse::getPosition(window);
std::cout << mouseCoord.x << " " << mouseCoord.y <<"\n";
sf::Event event;
while(window.pollEvent(event))
{
if(event.key.code == sf::Keyboard::Escape)
{
window.close();
}
}
window.clear();
window.draw(image);
window.display();
}
return 0;
}
These are the keys I tested, but I'm sure it affects far more, maybe even all of them
A: Always marked as true
B, C, D, E, F, G, H, I, J, K, L, M: The problem area seems to be around 0,n
Pause: The problem area seems to be around n,0
End, Home: 62,n+