SFML community forums

Help => General => Topic started by: slotdev on June 01, 2011, 10:49:36 am

Title: Mouse position calculation
Post by: slotdev 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
Title: Mouse position calculation
Post by: Laurent on June 01, 2011, 11:09:46 am
Code: [Select]
window.ConvertCoords(mouseX, mouseY);
Title: Mouse position calculation
Post by: slotdev on June 01, 2011, 11:20:02 am
Genius!

Thanks  :D
Title: Mouse position calculation
Post by: Laurent 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.