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

Author Topic: [SFML2] Getting mouse position in a sf::RenderWindow  (Read 3618 times)

0 Members and 2 Guests are viewing this topic.

chrbarrol

  • Newbie
  • *
  • Posts: 7
    • View Profile
[SFML2] Getting mouse position in a sf::RenderWindow
« on: July 11, 2011, 03:26:04 pm »
I recently switched over to SFML2 (which I might say has a lot of great features) but while I was trying to get the mouse position in my sf::RenderWindow I noticed that the mouse position code had been rewritten, so as far as I can tell from the documentation the sf::mouse is supposed to return the mouse's position from the window it is focused in.

But when I tried it out, GetPosition would just return the mouse's position on the screen(0,0 was always top left of the screen regardless of what window the cursor was in) I also noticed you could get the position for a specific window but only for a sf::Window and not a sf::RenderWindow. Does anyone know of a way to make this work? I'd rather not write a huge workaround that gets the window's position and normalizes the mouse based on that.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: [SFML2] Getting mouse position in a sf::RenderWindow
« Reply #1 on: July 11, 2011, 03:29:12 pm »
Quote from: "chrbarrol"
But when I tried it out, GetPosition would just return the mouse's position on the screen
I told Laurent that "GetDesktopPosition" would be a better name :D

Quote from: "chrbarrol"
I also noticed you could get the position for a specific window but only for a sf::Window and not a sf::RenderWindow.
sf::RenderWindow inherits sf::Window, so you can also pass a sf::RenderWindow.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[SFML2] Getting mouse position in a sf::RenderWindow
« Reply #2 on: July 11, 2011, 03:44:38 pm »
Quote
I told Laurent that "GetDesktopPosition" would be a better name

No... it's the online doc which is outdated ;)
Laurent Gomila - SFML developer

chrbarrol

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: [SFML2] Getting mouse position in a sf::RenderWindow
« Reply #3 on: July 11, 2011, 06:04:51 pm »
-snip- I figured it out. Thanks for the support anyway.