SFML community forums

Help => Window => Topic started by: vasyaslife on March 21, 2014, 10:10:53 pm

Title: How to keep my mouse in the window?
Post by: vasyaslife 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);
Title: Re: How to keep my mouse in the window?
Post by: eXpl0it3r on March 21, 2014, 11:30:54 pm
The forum search works fine, if you deselect all sub forums first and then only check the more important one. And then there's Google. ;)

See here (http://en.sfml-dev.org/forums/index.php?topic=14696.0) for a very recent discussion on that topic.
Title: Re: How to keep my mouse in the window?
Post by: vasyaslife on March 22, 2014, 06:51:28 am
Thx you so much :D