SFML community forums

Help => General => Topic started by: XeRaCKeR on January 18, 2014, 12:48:28 am

Title: Is possible to force mouse to stay in sf::RenderWindow?
Post by: XeRaCKeR on January 18, 2014, 12:48:28 am
Hi, I am learning OpenGL under SFML, and I am trying to move the 3D camera with mouse.

Is there any way to force the cursor to stay in the window? Since I can almost force it with the next code, but it doesnt work when you move the mouse so fast than the cursor can leave the window.

            case sf::Event::MouseMoved:
                // For camera rotation
                gradh += (event.mouseMove.x - (int)window.getSize().x/2)/7;
                grady += (event.mouseMove.y - (int)window.getSize().y/2)/7;
                // Force mouse to stay in the middle
                sf::Mouse::setPosition(sf::Vector2i(window.getSize().x/2,window.getSize().y/2),window);
                break;

Or another way to rotate the camera with mouse?

Sorry if bad english. Greetings
Title: Re: Is possible to force mouse to stay in sf::RenderWindow?
Post by: G. on January 18, 2014, 02:27:57 am
Maybe you could also react to the MouseLeave event.
Title: Re: Is possible to force mouse to stay in sf::RenderWindow?
Post by: zsbzsb on January 18, 2014, 02:41:51 am
http://en.sfml-dev.org/forums/index.php?topic=1876.0 (http://en.sfml-dev.org/forums/index.php?topic=1876.0)