Mouse Click Not Registering

I’m just attempting to debug my solution to verify that it’s working, but no mouse clicks are getting detected.

MouseState state = Mouse.GetState();
if(state.LeftButton == ButtonState.Pressed)


I’m putting a breakpoint inside the if and it is never getting hit. The If is getting hit every frame, but no matter what I click, it will not pick it up.

I am running Windows 8 and on a laptop, so I was wondering if that might have something to do with it. I tried it with both the mouse pad on my laptop and a mouse plugged in via USB, but no luck.

Any ideas? I’m running MonoGame 3.6.

The code is correct, so something else must be wrong somehow…

I am not sure why this is not working because as said above the code seems correct

I would do the following:
1/ Do not have MouseState state = Mouse.GetState(); in every loop. Declare MouseState state; as a variable, and have state = Mouse.GetState(); in the Loop

2/ Debug to the console and write to the console in every loop

if(state.LeftButton == ButtonState.Pressed)
Console.WriteLine(“Left button pressed”);
else if(state.RightButton == ButtonState.Pressed)
Console.WriteLine(“Right button pressed”);
Console.WriteLine(“No button pressed”);

If you are using Visual Studio you can check the console log by going to Project --> xx Properties --> Application --> Out put type: Console Application

This was the #1 search result for my issue so I’m going to post my answer here even though it’s situational.

I have a monogame app that worked 10 years ago and not today and it was displaying the game window in a windows forms bitmap and WinFormsGameWindow._form.Visible was always = false which causes it not to make mouse events. I was able to undo the code preventing it from doing mouse events in the Monogame source code by removing from UpdateMouseState():

if (!_form.Visible)