[CLOSED] Clip getEventDY/DX to window.

Started by Feskmaws, November 14, 2011, 00:51:31

Previous topic - Next topic

Feskmaws

Hello.

I'm working on an application which includes dragging windows inside the display (all done in OpenGL). When I hold down either mouse button and move outside the window, the getEventDX/DY functions returns the real values for mouse movement, but I think it would make more sense if they returned the difference between the clipped coordinates for the mouse event, at least when Mouse.setClipMouseCoordinatesToWindow(true) is set. Alternatively, an option for this kind of behaviour would be nice :).

jediTofu

cool story, bro

Feskmaws

I can't get that to work :-\. When I try having it in a static block, it says it can't find the field, and when I try passing it as VM arguments it can't find the main class. This might very likely be a problem on my end since I'm not very good with this aspect of java developing.

Anyway, since setClipMouseCoordinatesToWindow() should already do what I understand org.lwjgl.input.Mouse.allowNegativeMouseCoords is meant to do and more, it probably isn't enough.

I checked the values for X, DX, Y and DY with the following lines everytime a mouse event occured:

System.out.println("X = " + Mouse.getEventX() + " Y = " + Mouse.getEventY());
System.out.println("DX = " + Mouse.getEventDX() + " DY = " + Mouse.getEventDY());


When moving the mouse below and to the left of the window, X and Y are both 0, but DX and DY are not. Again, it only behaves like this when either mouse button is held down since it doesn't generate events otherwise.

noblemaster

I am having the same problem. I tried both setClipMouseCoordinatesToWindow(...) and org.lwjgl.input.Mouse.allowNegativeMouseCoords but I am only able to get coordinates outside the window (including negative coordinates) when the mouse button is pressed, i.e. for dragging.

Would it be possible to get coordinates for when the mouse is outside the window even if the mouse buttons are not pressed? Maybe there is an option/setting we are not aware of?

To bring it into context: getting the mouse coordinates outside the window is important for left/right/up/down scrolling of an isometric map (e.g. ala Age of Empires). It's difficult to decide where to scroll the isometric map if I am not sure what position outside the window the mouse has (windowed mode).

Matzon

Technically, on windows, it's impossible to get mouse movement events outside the window unless we create a system hook. I dont think we plan on doing that. I think there are some anti-virus programs that react to that.

Why not just grab the cursor and draw your own?

kappa

I don't think the getEventDX() and getEventDY() behaviour here is wrong or should be changed as per the RFE. The DX and DY values simply reflect the amount the mouse has moved and therefore shouldn't be effected by any mouse coordinate clipping.

The behaviour the Op is looking for can be obtained by using getX(), getY() (or getEventX() and getEventY()) and calculating your own DX, DY values with checks on windows bounds to get the special outside window behaviour Op needs.