Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to keep my mouse in the window?  (Read 1512 times)

0 Members and 1 Guest are viewing this topic.

vasyaslife

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
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);

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: How to keep my mouse in the window?
« Reply #1 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 for a very recent discussion on that topic.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

vasyaslife

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: How to keep my mouse in the window?
« Reply #2 on: March 22, 2014, 06:51:28 am »
Thx you so much :D