Cursor jump on when click an object (when turn on cursor and "drag to rotate" mode)

After turning on cursor and activating “drag to rotate” mode, whenever I click on the cube, the cursor unexpectedly “jump” on (from the place where I click) several inches (on screen). I have no idea why.
I try using both mouse and touch pad, but it’s useless.

I think after watching this video, you will know exactly what problem I’m dealing with.

Video describes my problem

Here is the code I used to turn on cursor and “drag to rotate” mode.


I’m currently using jmonkey 3.0 for Mac OS X
Before using Mac, I used to use a Windows laptop and this problem never happened , until I change from Windows to Mac OS X.
Could anyone help me?
Thank you in advance.

Does your Mac have a retina display?

No, It does not have a retina display. (I’m using Macbook Pro Mid 2012)

Not only objects, whenever I click anywhere on the screen, the cursor jumps on.

Does it jump back to the center of the screen? Your video is marked as private so I couldn’t see.

I’ve just changed it to ‘public’ .
The cursor jumps on (from where I click) .

Now that I can see your video… I’m not sure.

I do dragging all the time without this issue. I assume this is just a simple test that you have written? If so can you post the source code to it?

To make sure that this issue is not caused by me. I copied a chunk of code from jmonkey book.
And it’s true, it’s not due to the code, it’s something else.
I’m quiet new with jmonkey, I’ve just picked up a jmonkey book for several days, and felt really interested and excited . (before that, I’m a Java coder, and I code for cash … believe me or not :smile: ) ) . The code in the book is so nice, and I think I’ve ‘fell in love with jmonkey’, but that’s before this issue come out.
I’m sure that this problem was not caused by code. And It made me feel so dump because I have no idea what’s going on. (I’ve tried everything I can come up with: try using mouse, touch pad, clean build again, writing another chunk of code,.etc)

Well, it would still help us to see the code you are trying to run.

Here is the code:

import com.jme3.collision.CollisionResults;
import com.jme3.input.MouseInput;
import com.jme3.input.controls.AnalogListener;
import com.jme3.input.controls.MouseButtonTrigger;
import com.jme3.input.controls.Trigger;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Matrix4f;
import com.jme3.math.Ray;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;

public class Main extends SimpleApplication {
    private static final Trigger TRIGGER_ROTATE = 
            new MouseButtonTrigger(MouseInput.BUTTON_LEFT);
    private static final String MAPPING_ROTATE = "Rotate";
    private AnalogListener analogListener = new AnalogListener() {
        public void onAnalog(String name, float value, float tpf) {
               CollisionResults results = new CollisionResults();
               Vector2f click2d = inputManager.getCursorPosition();
               Vector3f click3d = cam.getWorldCoordinates(
                       new Vector2f(click2d.getX(), click2d.getY()), 0f);
               Vector3f direction = cam.getWorldCoordinates(
                       new Vector2f(click2d.getX(), click2d.getY()), 1f).subtractLocal(click3d);
               Ray ray = new Ray(click3d, direction);
               rootNode.collideWith(ray, results);
               if(results.size() > 0){
                   Geometry target = results.getClosestCollision().getGeometry();
                   target.rotate(0.0f, value, 0.0f);
    public static void main(String[] args) {
        new Main().start();

    public void simpleInitApp() {
        rootNode.attachChild(makeCube("Red cube",
                new Vector3f(0f,1.5f,0f), ColorRGBA.Red));
        rootNode.attachChild(makeCube("Blue cube", 
                new Vector3f(0f,-1.5f,0f), ColorRGBA.Blue));
        inputManager.addMapping(MAPPING_ROTATE, TRIGGER_ROTATE);
        inputManager.addListener(analogListener, new String[]{MAPPING_ROTATE});

    public void simpleUpdate(float tpf) {}

    public void simpleRender(RenderManager rm) {}
    public Geometry makeCube(String name, Vector3f location, ColorRGBA color){
        Box box = new Box(Vector3f.ZERO, 1, 1, 1);
        Geometry geom = new Geometry(name, box);
        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", color);
        return geom;
    public void attachCenter(){
        Geometry c = makeCube("Center square", Vector3f.ZERO, ColorRGBA.White);
        c.setLocalTranslation(cam.getWidth()/2, cam.getHeight()/2, 0.0f);

And one more video.

As you can see, when I click on the red cube, the cursor ‘jump’ to the blue cube, and as I continue clicking, the red cube still rotate (not the blue). And vice versa, when I click on the blue cube, the cursor jump to the red cube, and as I continue clicking (and holding for awhile ), the blue cube rotate (not the red cube). This’s so … strange.

Does the cursor work fine when you leave the jME context?

Yep! It works fine. This problem occurs only when I turn on the cursor and “drag to rotate” mode in jMonkey. But when I move back to Windows, it vanishes. I cannot figure it out, as I said above, I’ve tried anything I can. I don’t know whether there are any people that have the same problem like me when they’re using jMonkey on a Mac, but I think it maybe somehow due to jMonkey not completely compatible with Mac OS X,… that’s just a conjecture (as there’s nothing that I can rely on to prove this is true).
I’m currently using Mac OS X Yosemite 10.10.2 , (Macbook pro mid 2012 : 13 inches, core i5 , intel graphics HD4000. )
Once again, before this problem happens, I used to use a Windows laptop, and this problem never took place.

Can anyone help me?
… or I have to pretend to ignore this issue and then keep learning other stuff. :frowning:

Seems like it might be specific to the particular environment. Not sure what the issue is, personally.

Maybe others have experienced it and can help… but I looked through the JME code and I can’t find anywhere that JME is setting the cursor location at all.

@pspeed Thank you for your help. I think that I have no choice, ignore it and keep learning ,or I can move back to Windows , but I sold that laptop … Ironically!

I ran the code on my windows pc but I do not get that problem you are experiencing.
Like @pspeed said it might be an environment issue.

I just tried it on Linux with openJDK and oracleJDK (7 and 8 with both) and no problem found.

I am also reading the jMonkey Beignner’s Guide, and the code works fine for me. I am running ubuntu 14.04lts and Oracle jdk, with nvidia gt750m.

Try refreshing your system? or something similar…

Has it ever happened before, or only happening with jME? Like everyone else is saying, it could be something one your system that’s causing the issue.

I moved 3 posts to a new topic: Total beginner in programming needs help

I have the same issue on my mac =)

os x 10.10.3, macbook pro 15 inch retina display