Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse position does not change when left button is pressed on macOS #5296

Closed
njlr opened this issue Nov 14, 2016 · 2 comments
Closed

Mouse position does not change when left button is pressed on macOS #5296

njlr opened this issue Nov 14, 2016 · 2 comments
Labels
Input Related to input (keyboard, mouse, touch, gamepad) MacOS

Comments

@njlr
Copy link

njlr commented Nov 14, 2016

I am using MonoGame 3.6.0.906 on MacOS. I am trying to get some mouse input code working, but I have found some strange behaviour. It appears that the mouse position does not update when the left button is pressed. This makes it impossible to implement mouse dragging input.

To investigate, I added print statements when the left mouse button is pressed, when is released and the mouse position every update. I then tried clicking and dragging. The mouse definitely moved when the left button was down.

Here is the log:

...
{X:89 Y:384}
{X:89 Y:385}
{X:90 Y:386}
pressed
released
{X:91 Y:386}
{X:94 Y:386}
{X:96 Y:386}
...

As can be seen, the mouse position does not change when the left button is down.

Here is the code:

    MouseState previousMouseState;

    protected override void Update(GameTime gameTime)
    {
        var mouseState = Mouse.GetState();

        if (mouseState.LeftButton == ButtonState.Pressed && 
            previousMouseState.LeftButton == ButtonState.Released)
        {
            Console.WriteLine("pressed");
        }

        if (mouseState.LeftButton == ButtonState.Released && 
            previousMouseState.LeftButton == ButtonState.Pressed)
        {
            Console.WriteLine("released");
        }

        if (mouseState.Position != previousMouseState.Position)
        {
            Console.WriteLine(mouseState.Position);
        }

        previousMouseState = mouseState;

        base.Update(gameTime);
    }

SO question: http://stackoverflow.com/questions/40562644/why-does-my-mouse-position-not-update-when-the-left-button-is-pressed

@njlr
Copy link
Author

njlr commented Nov 14, 2016

For a MonoMac application it works correctly. The problem occurs when using the cross platform desktop template, the Xamarin Mac template and the Xamarin Classic template.

@mrhelmut
Copy link
Contributor

Hi,

Would you mind updating to the latest development version? This problem should have been fixed for quite some time now, but what's puzzling is that 3.6.0.906 should have this fix in.

@Jjagg Jjagg added MacOS Input Related to input (keyboard, mouse, touch, gamepad) labels Dec 10, 2018
@Jjagg Jjagg closed this as completed Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Input Related to input (keyboard, mouse, touch, gamepad) MacOS
Projects
None yet
Development

No branches or pull requests

3 participants