# Get Mouse Position Stuck at Value While Mouse Button Pressed

**URL:** <https://forums.unrealengine.com/t/get-mouse-position-stuck-at-value-while-mouse-button-pressed/390659>\
**Category:** UI\
**Tags:** mouse-cursor, unreal-engine, Widget, mouse-position, Blueprint, question\
**Created:** [April 12, 2017, 2:42am UTC](https://forums.unrealengine.com/t/get-mouse-position-stuck-at-value-while-mouse-button-pressed/390659 "2017-04-12T02:42:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_77db0c85](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_77db0c85](https://forums.unrealengine.com/u/anonymous_user_77db0c85)\
**Post date:** [April 12, 2017, 2:42am UTC](https://forums.unrealengine.com/t/get-mouse-position-stuck-at-value-while-mouse-button-pressed/390659/1 "2017-04-12T02:42:53Z")

</div>

Below is a Youtube video demoing the issue. In short, when I click I can no longer move my mouse. I believe I have narrowed it down to the Get Mouse Position function. Is there a different function I should be using to get the current mouse position. It updates the position of one of my UI widgets.  
Thanks for any help!

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/e/2/1e2ab295eaa1a8b5db1aef5f10844b253ac7f637.jpeg "UE4: Get Mouse Position Stuck at Value While Mouse Button Pressed") ](https://www.youtube.com/watch?v=seN93SiA-yc)

 ![133874-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/1/3/213e1909831c53cd385b502fde6b3fe704a583ed.png)

---

<div class="post-metadata">

**Author:** ![HPBrocraft](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HPBrocraft](https://forums.unrealengine.com/u/HPBrocraft)\
**Post date:** [April 28, 2017, 8:08pm UTC](https://forums.unrealengine.com/t/get-mouse-position-stuck-at-value-while-mouse-button-pressed/390659/2 "2017-04-28T20:08:36Z")

</div>

I just ran unto the same issue. I don’t know why GetMousePosition doesn’t update when a mouse button is held, it may be by design, but this blueprint might help. What I did was store the mouse position when the button is pressed and then update that position every event tick using GetMouseX and GetMouseY. I had to invert the Y because I was drawing something in the HUD that had to follow the cursor. I know you have a different issue to solve but maybe this can give you some ideas.

 ![136008-mouseposition.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/f/c/ffc8efd7f8deab0946bcd1f5c4107c13cd3bbef0.png)

---

<div class="post-metadata">

**Author:** ![chricken](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@chricken](https://forums.unrealengine.com/u/chricken)\
**Post date:** [September 17, 2018, 6:46pm UTC](https://forums.unrealengine.com/t/get-mouse-position-stuck-at-value-while-mouse-button-pressed/390659/3 "2018-09-17T18:46:32Z")

</div>

The “Get Mouse Position on Viewport” function seems to be working pretty well, even with pressed mousebutton.

---

<div class="post-metadata">

**Author:** ![zos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zos](https://forums.unrealengine.com/u/zos)\
**Post date:** [September 16, 2022, 5:28am UTC](https://forums.unrealengine.com/t/get-mouse-position-stuck-at-value-while-mouse-button-pressed/390659/4 "2022-09-16T05:28:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zos](https://forums.unrealengine.com/u/zos)\
**Post date:** [September 16, 2022, 5:40am UTC](https://forums.unrealengine.com/t/get-mouse-position-stuck-at-value-while-mouse-button-pressed/390659/5 "2022-09-16T05:40:10Z")

</div>

Yes as I suspected, I can confirm that either `SetClickMethod(MouseDown)` or `SetClickMethod(PreciseClick)` fixes it. `MouseDown` has the effect of calling `OnClicked` immediately `OnPressed`, but you still receive `OnReleased` events as normal. `PreciseClick` seems to fire the `OnReleased` event when you move the mouse and I guess doesn’t fire `OnClicked` when this happens.

---

<div class="post-metadata">

**Author:** ![Evan\_Patterson](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Evan\_Patterson](https://forums.unrealengine.com/u/Evan_Patterson)\
**Post date:** [March 10, 2025, 9:37pm UTC](https://forums.unrealengine.com/t/get-mouse-position-stuck-at-value-while-mouse-button-pressed/390659/6 "2025-03-10T21:37:34Z")

</div>

I had the same issue with the mouse events in my widgets causing an issue with GetMousePosition. Like the other guy here suggested you can use “GetMousePosition on Viewport”, but you have to scale it using the viewport geometry. Here’s the BP:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/e/d/1edade2420d17a9c32f3f0928b5ed7d006daf7c5.png)

I’m using this to control the mouse using gamepad input.
