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

Author Topic: Mouse position calculation  (Read 1459 times)

0 Members and 1 Guest are viewing this topic.

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Mouse position calculation
« on: June 01, 2011, 10:49:36 am »
Hi

Is there a way to automatically have SFML tell me the co-ordinates of the mouse, when I have a large window and all graphics are being scaled?

eg. I have a button at X=100, Y=100 (at 1024x768) but at 1280x1024 it's (of course) at a different position on the screen.

Thanks
SFML 2.1

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Mouse position calculation
« Reply #1 on: June 01, 2011, 11:09:46 am »
Code: [Select]
window.ConvertCoords(mouseX, mouseY);
Laurent Gomila - SFML developer

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Mouse position calculation
« Reply #2 on: June 01, 2011, 11:20:02 am »
Genius!

Thanks  :D
SFML 2.1

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Mouse position calculation
« Reply #3 on: June 01, 2011, 11:40:17 am »
Quote
I check for events
Code: [Select]
myWindow.ConvertCoords(Event.MouseMove.X,Event.MouseMove.Y);
eventData.clickPosX = mousePos.x; // Might need a cast
eventData.clickPosY = mousePos.y;

Where are these lines located in your code?
And you're not storing the result of the function.
Laurent Gomila - SFML developer

 

anything