Skip to content

starting in 3.10.0-beta1, InputManager.setCursorVisible() re-centers the cursor #2936

Description

@stephengold

In 3.9.0-alpha4 and earlier builds of JME, invoking inputManager.setCursorVisible() has no effect on the position of the mouse cursor.

In 3.9.0-beta1 and 3.9.0-beta2, inputManager.setCursorVisible() causes the cursor to jump to the center of the window.

Here is a test app:

package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.input.controls.Trigger;

public class Main extends SimpleApplication implements ActionListener {

    public static void main(String[] args) {
        new Main().start();
    }

    @Override
    public void simpleInitApp() {
        // Configure the input mapping:
        Trigger tabTrigger = new KeyTrigger(KeyInput.KEY_TAB);
        String toggleAction = "toggle cursor";
        inputManager.addMapping(toggleAction, tabTrigger);
        inputManager.addListener(this, toggleAction);

        // Pressing the TAB key invokes this.onAction() below.
    }

    @Override
    public void onAction(String string, boolean isPressed, float tpf) {
        if (isPressed) { // toggle cursor visibility:
            boolean isVisible = inputManager.isCursorVisible();
            boolean makeVisible = !isVisible;
            inputManager.setCursorVisible(makeVisible);
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions