How to set the location of the cursor? or: How to stop autoscroll at start?

I just started toying around with jme3 (nice work there, quite easy to play around thanks to the turorials :slight_smile: ), and already managed to not find a solution to this newbie problem.

How do I force the mouse cursor to a location? We got a getCursorPosition(), but I can’t find any setter.



I don’t even know yet if this would solve my problem, or if it’s something else. I toyed around with a strategy game view, did manage to get it scrollable:

[java] if(inputManager.getCursorPosition().x < 10) {

cam.setLocation(new Vector3f(cam.getLocation().x-0.03f,cam.getLocation().y,cam.getLocation().z));

}

if(inputManager.getCursorPosition().x > resolution[0]-11) {

cam.setLocation(new Vector3f(cam.getLocation().x+0.03f,cam.getLocation().y,cam.getLocation().z));

}

if(inputManager.getCursorPosition().y < 10) {

cam.setLocation(new Vector3f(cam.getLocation().x,cam.getLocation().y-0.03f,cam.getLocation().z));

}

if(inputManager.getCursorPosition().y > resolution[1]-11) {

cam.setLocation(new Vector3f(cam.getLocation().x,cam.getLocation().y+0.03f,cam.getLocation().z));

}[/java]



But for some reason it always scrolls to the bottom left until I move the mouse for the first time, my thoughts so far was that the cursor got the coordinates (0,0) until it gets “activated” when I move it the first time, so I wanted to try to preset it’s location somehow.

There is the Robot class in java perhaps could work.



[java]Robot rob = new Robot();

rob.mouseMove(x, y);[/java]

Tried using it, it did move the cursor but afterwards it crashes java (thus leading to my application beeing frozen). No idea why it would do that :confused:

Any tips about the start-scroll except moving the cursor away?