1
Window / How to keep my mouse in the window?
« on: March 21, 2014, 10:10:53 pm »
Hello!
How i can keep mouse in my created window (app) all the time and don't let it go from it?
i used this method but it's working very bad. Have any idea?
if (focus == true && Mouse::getPosition(app).x < 0) Mouse::setPosition(sf::Vector2i(0, Mouse::getPosition(app).y), app);
if (focus == true && Mouse::getPosition(app).x > xResolution) Mouse::setPosition(sf::Vector2i(xResolution - 5, Mouse::getPosition(app).y), app);
if (focus == true && Mouse::getPosition(app).y < 0) Mouse::setPosition(sf::Vector2i(Mouse::getPosition(app).x, 0), app);
if (focus == true && Mouse::getPosition(app).y > yResolution) Mouse::setPosition(sf::Vector2i(Mouse::getPosition(app).x, yResolution - 5), app);
How i can keep mouse in my created window (app) all the time and don't let it go from it?
i used this method but it's working very bad. Have any idea?
if (focus == true && Mouse::getPosition(app).x < 0) Mouse::setPosition(sf::Vector2i(0, Mouse::getPosition(app).y), app);
if (focus == true && Mouse::getPosition(app).x > xResolution) Mouse::setPosition(sf::Vector2i(xResolution - 5, Mouse::getPosition(app).y), app);
if (focus == true && Mouse::getPosition(app).y < 0) Mouse::setPosition(sf::Vector2i(Mouse::getPosition(app).x, 0), app);
if (focus == true && Mouse::getPosition(app).y > yResolution) Mouse::setPosition(sf::Vector2i(Mouse::getPosition(app).x, yResolution - 5), app);