Mouse position not updating when holding left mouse button?

Hi all,

I posted this same issue in the C++ forums but I thought I might post it here too as it feels like a possible bug.

In all previous engine versions this hasn’t been a problem, (I moved straight from 4.9 to 4.11) it’s only when updating to 4.11 that this has now become a problem for me. When holding the Left Mouse button and dragging the mouse around, the engine doesn’t seem to update the mouse position at all, instead it completely locks it in place where I originally held the Left Mouse Button.

Is there a method to release this lock or is this a possible bug?

The problem I’m currently having is that I’m trying to drag actors around the level but now I’m unable to do so due to the mouse position not updating when holding down the Left Mouse Button.

Thanks,
Jon

1 Like

Hey ZeJudge-

Are you referring to the mouse not updating while playing (in PIE or standalone) or when working in the editor viewport itself? What are you trying to drag around the level? In my tests I was able to add a new mesh / blueprint to the level and grad the transform arrows to move it around. If you don’t have anything selected when you hold the button, are you able to fly the viewport camera around (forward / backward as well as spin around)?

Hi ,

I have created an in-game level editor.
This is happening when in-game using PIE or Standalone. While holding down the left mouse button the mouse cursor disappears and locks into position. This is making it difficult for me to select my custom actors in the in-game level and move them around with the left mouse cursor. I am able to bind the same movement functionality to another key on the keyboard and my logic works perfectly, only with the Left Mouse button does the cursor seem to disappear and lock, unable to move.

The logic should be very simple as it works with any other key, apart from when holding down the left mouse button:

PC->DeprojectScreenPositionToWorld(GetMousePos.X, GetMousePos.Y, WorldLoc, WorldDir);
FVector NewBuildPosition = WorldLoc + WorldDir * ActorDistance;
ManipActor()->SetActorLocation(NewBuildPosition);

I’ve also tried a Deproject method from my HUD class directly from the Canvas (which was my original method before using the above) but still no luck which is making me feel as though something has changed within the Engine concerning this since 4.9.

Cheers,
Jon

To prevent the cursor from disappearing when holding the button you can set PlayerController::bShowMouseCursor to true to allow the mouse to still interact with the game and remain visible as it moves around the viewport.

Cheers

I already have that set in a number of places.
I’m using a Toggle instead now so that I left click once to enable the dragging of an actor, then right click to release as holding down left mouse button just isn’t working for me anymore, I have no idea why.

Cheers for taking the time to respond , much appreciated.

Cheers,
Jon

I was having the same issue after updating an old project, and after a ton of digging finally found the culprit (in my case).

It seems the ‘Player Controller → Set Input Mode Game and UI’ Blueprint node now has a ‘Hide Cursor During Capture’ option, and it defaults to ‘true’. When that option is enabled the mouse disappears when any mouse button is held, and the position is essentially held in-place (there seems to be some sub-frame updates that still go through, but at some point every frame the mouse position snaps back to the original click position).

Disabling that option immediately fixed the issue for me, the mouse stayed visible and the position updated continuously. I’m not sure if it’s a bug with that option, or if that’s the intended behavior - seems like a bug to me since it’s actually changing the mouse input rather than just hiding the cursor.

7 Likes

Have a look here

Cheers,

I just wanted to say thank you for this answer - this has caused me so much grief, and I’m glad to have found the cure.

Wow thx! Searched the whole weekend for a solution. This has finally fixed it, an should be marked as correct answer :slight_smile:

Not to necro an old thread, but THANK YOU!

In SButton::OnMouseButtonDown , depending on the EButtonClickMethod , the Reply will be marked with FReply::Handled().CaptureMouse( AsShared() ); , which “captures the mouse”. This is what is causing GetMousePosition not to update while a mouse button is pressed. If you use one of the other ButtonClickMethods like MouseDown or PreciseClick you won’t get this effect.

The mouse cursor position on the screen updates, but the value returned by GetMousePosition (on for example PlayerController) still remains constant while the mouse is captured. (See my answer, for a non-capturing UMG UButton set the click method to either MouseDown or PreciseClick)