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

Author Topic: SFML2 - desktop mouse vs. renderwindow mouse [SOLVED]  (Read 2921 times)

0 Members and 1 Guest are viewing this topic.

Brendon

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
    • http://blendogames.com
SFML2 - desktop mouse vs. renderwindow mouse [SOLVED]
« on: September 25, 2011, 08:37:04 pm »
I'm currently updating my project to the latest SFML2. In the new input system, I noticed my desktop mouse and renderwindow mouse are located at two different locations:



Moving one cursor also moves the other. Cosmetically, I don't mind. But functionally, I have a problem in that left-clicking will de-focus the renderwindow and select the underlying desktop.

Has anyone experienced a similar problem, or does my input code need some massaging?

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
SFML2 - desktop mouse vs. renderwindow mouse [SOLVED]
« Reply #1 on: September 25, 2011, 08:55:56 pm »
Are you using sf::Mouse::SetPosition ?

If so, make sure you are using sf::Mouse::SetPosition(const Vector2i& position, const Window& relativeTo) and not sf::Mouse::SetPosition(const Vector2i& position).
SFML / OS X developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
SFML2 - desktop mouse vs. renderwindow mouse [SOLVED]
« Reply #2 on: September 25, 2011, 08:56:05 pm »
Hmm the input system has had a pretty big make over if you missed it. Look at sf::Mouse for more information about getting real-time mouse data.
http://www.sfml-dev.org/documentation/2.0/classsf_1_1Mouse.php

Though there is still the problem that you can't clip the mouse to the window using SFML. But I guess your not interested in that.

I'll stay tuned to your next game ;)
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Brendon

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
    • http://blendogames.com
SFML2 - desktop mouse vs. renderwindow mouse [SOLVED]
« Reply #3 on: September 25, 2011, 09:20:04 pm »
Thanks all, that solved the problem. I was grabbing the mouse relative to the desktop and not relative to the renderwindow.

My mouse code was:
Code: [Select]
this.mousePosX = SFML.Window.Mouse.GetPosition().X;
this.mousePosY = SFML.Window.Mouse.GetPosition().Y;


And the correct way to do it is:
Code: [Select]
this.mousePosX = SFML.Window.Mouse.GetPosition(myRenderWindow).X;
this.mousePosY = SFML.Window.Mouse.GetPosition(myRenderWindow).Y;

 

anything