LaurentGomila/SFML — Issue #124: ConvertCoord with negative mouse coordinates (drag&drop)
Author: Beuc
Created: 2011-11-13 15:53:14+00:00
State: open

Hi,

I'm implementing a google-maps-style viewer to browse my game map. When the user clicks, it switches to drag mode, and mouse movements are translated to reverse camera movements using RenderWindow::ConvertCoords.

```c++
if (drag_on && event.Type == sf::Event::MouseMoved) {
sf::Vector2i window_now(event.MouseMove.X, event.MouseMove.Y);
sf::Vector2f map_delta = App.ConvertCoords(window_now.x, window_now.y)
- App.ConvertCoords(window_last_click.x, window_last_click.y);
view.Move(-map_delta); // camera movement is the opposite of the map movement
window_last_click = window_now;
}
```

This works fine, but when the mouse goes out of the window by the left or the top, RenderWindow::ConvertCoord converts the negative int mouse coordinates to positive unsigned int coordinates, aka something like 4.29497e+09 - which is incorrect.

Is there a reason why WindowX and WindowY are "unsigned" in the ConvertCoords prototype?
```c++
sf::Vector2f RenderWindow::ConvertCoords(unsigned int WindowX, unsigned int WindowY, const View* TargetView) const
```
At first glance, I would suggest removing the "unsigned".