# How to Show Mouse Cursor without losing mouse capture?

**URL:** <https://forums.unrealengine.com/t/how-to-show-mouse-cursor-without-losing-mouse-capture/578191>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [June 9, 2022, 9:19pm UTC](https://forums.unrealengine.com/t/how-to-show-mouse-cursor-without-losing-mouse-capture/578191 "2022-06-09T21:19:36Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![xi57](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/xi57/32/1194660_2.png) [@xi57](https://forums.unrealengine.com/u/xi57)\
**Post date:** [June 9, 2022, 9:19pm UTC](https://forums.unrealengine.com/t/how-to-show-mouse-cursor-without-losing-mouse-capture/578191/1 "2022-06-09T21:19:36Z")

</div>

_Edit: Found the answer: [Tutorial: How to Take Control of the Mouse in Lyra/CommonUI - YouTube](https://www.youtube.com/watch?v=A9dp3cmCFtQ)_

I’m working on an RTS style interface. The camera is panning based on mouse movement and in general works great as long as the mouse cursor is hidden.

If I call `PlayerController->SetShowMouseCursor(true)` then everything gets messed up.

With a visible mouse cursor, character movement and camera panning works fine UNTIL I click the right or left mouse button. As soon as I click one of those buttons, then camera panning STOPS ENTIRELY and there is no way to get it back. It seems that Unreal hijacks the mouse once I click something.

Again, note that this IS NOT A PROBLEM if I leave the mouse hidden. It is specifically the call to `PlayerController->SetShowMouseCursor(true)` which seems to be the problem.

Is there some other different/better way to show the mouse cursor that doesn’t have these unintended consequences of completely breaking the input system?

(In case it matters, I’m using Lyra’s Enhanced Input System, but from what I’ve read, this seems to be a fundamental issue with UE’s input handling; It’s not at all clear how to solve this except perhaps to implement my own mouse cursor and NOT use the system PlayerController mouse cursor, but surely there is a better way?)

Please and thanks in advance.

---

<div class="post-metadata">

**Author:** ![CorsairOfLight](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/corsairoflight/32/485641_2.png) [@CorsairOfLight](https://forums.unrealengine.com/u/CorsairOfLight)\
**Post date:** [June 9, 2022, 9:28pm UTC](https://forums.unrealengine.com/t/how-to-show-mouse-cursor-without-losing-mouse-capture/578191/2 "2022-06-09T21:28:09Z")

</div>

I don’t know if this will work, but maybe setting a lock on your mouse events will keep the hijack from happening. Use a boolean and branch to set the lock during these pans.

If the mouse still works after that, then I don’t know what’s going on and you may want to bring it up to Epic.

---

<div class="post-metadata">

**Author:** ![xi57](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/xi57/32/1194660_2.png) [@xi57](https://forums.unrealengine.com/u/xi57)\
**Post date:** [June 9, 2022, 10:12pm UTC](https://forums.unrealengine.com/t/how-to-show-mouse-cursor-without-losing-mouse-capture/578191/3 "2022-06-09T22:12:01Z")

</div>

I’m using the Enhanced Input System that Epic set up for LyraStarterGame.

The one and only change that I’ve made is that I changed the input such that the mouse input doesn’t pan the camera unless the middle mouse button is also pressed. This way I can move the mouse around the screen and click on things independently of panning the camera.

I’ve done nothing at all with the left or right clicks, which are the things that are breaking the input IF and only if the mouse cursor is visible.

Somewhere deep in UE it’s doing something like “if cursor is visible, don’t let mouse input get to the game.”

I’ve tried various forms of `SetInputMode()` but none of them seem to do what I want, which is to have the mouse be visible AND still send the enhanced input system mouse movement events to the game.

---

<div class="post-metadata">

**Author:** ![xi57](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/xi57/32/1194660_2.png) [@xi57](https://forums.unrealengine.com/u/xi57)\
**Post date:** [June 9, 2022, 11:14pm UTC](https://forums.unrealengine.com/t/how-to-show-mouse-cursor-without-losing-mouse-capture/578191/4 "2022-06-09T23:14:19Z")

</div>

To follow up, I’m several hours into this problem and I haven’t been able to find any way to do this the “right” way, if there is such a thing.

Instead, I’m just leaving the mouse invisible and I created a custom HUD class that draws a rectangle where the mouse is supposed to be. It’s crude, but at least the input consistently works now.

I guess at some point I’ll try to make it look like a mouse.

---

<div class="post-metadata">

**Author:** ![Noridos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Noridos](https://forums.unrealengine.com/u/Noridos)\
**Post date:** [June 11, 2022, 9:25pm UTC](https://forums.unrealengine.com/t/how-to-show-mouse-cursor-without-losing-mouse-capture/578191/5 "2022-06-11T21:25:14Z")

</div>

Same Issue here, but in third parson.  
After opening widget im showing cursor removing mapping and add new mapping then on close im removing mapping and adding old one, cursor is hidden but camera dont recive any input, i need to click to get back mouse capture.

For now i have put " set input mode Game Only " at the end and it works

 ![Input_issue](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/1/0/c100a002d1e9906e5a6fb1ffdd8623379f473191.jpeg)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_da4075d8](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_da4075d8](https://forums.unrealengine.com/u/anonymous_user_da4075d8)\
**Post date:** [August 19, 2022, 8:09pm UTC](https://forums.unrealengine.com/t/how-to-show-mouse-cursor-without-losing-mouse-capture/578191/6 "2022-08-19T20:09:47Z")

</div>

Hello!

I found a solution for this problem, thought I am a complete amateur with Unreal Engine still. You need to change 2 different settings sections to get it working.

1. In project settings, search for Mouse under Engine Input, and set them to this:  
 ![Engine Input](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/3/8/7386e490565dcc666afba04221fdabeed266723d.png)

2. In your PlayerController class, in the Details panel, search Mouse, and set them to this:  
 ![PlayerController](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/8/3/683dbed458b9175bc622e5895beb23330867bf71.png)

---

<div class="post-metadata">

**Author:** ![xi57](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/xi57/32/1194660_2.png) [@xi57](https://forums.unrealengine.com/u/xi57)\
**Post date:** [February 3, 2023, 3:02am UTC](https://forums.unrealengine.com/t/how-to-show-mouse-cursor-without-losing-mouse-capture/578191/7 "2023-02-03T03:02:22Z")

</div>

I finally got a chance to dive into this to see how to fix it.

I’ll try to make a full tutorial for this later, but for now here is the procedure:

> <https://github.com/x157/x157.github.io/issues/14>
>
> As of UE 5.1, this code implicitly changes the input mode to Menu: (maybe only i…f you start in \`Game\` input mode?)
> \`\`\`c++
> PlayerController-\>SetShowMouseCursor(true);
> \`\`\` 
> 
> And this code does not change the input mode at all:
> \`\`\`c++
> PlayerController-\>SetShowMouseCursor(false);
> \`\`\`
> 
> This means any time I want to show/hide the mouse as a part of normal game play I need to explicitly manage the input mode and mouse capture settings every time the mouse visibility changes.
> 
> In my case, I'm trying to use a widget that is on \`UI.Layer.Game\` that is sometimes active and sometimes not active. I do not want all the input to stop working for the game, I just want the user to be able to click a widget if they want to, or not click it, \*\*while still playing the game\*\*.
> 
> Ultimately I solved the problem by overriding \`ULyraHUDLayout::GetDesiredInputConfig\` such that it returns a different config for when I want the mouse to be visible during gameplay compared to what it returns when I want the mouse to be invisible. (Also had to explicitly disable \`bIsFocusable\` for the HUD Layout, or it sometimes starts stealing input).
> 
> This also required overriding the base \`ULyraActivatableWidget::GetDesiredInputConfig\` to manage look input ignore settings in the various scenarios since Lyra provides no visibility into or access to set look input ignore preferences.
> 
> Finally, a complete and total overhaul of \`UCommonUIActionRouterBase::ApplyUIInputConfig\` was required, I literally had to throw out that entire method and rewrite it all to get it to work. Part of that included not completely ignoring look/move input ignore preferences like it does by default. (In 5.1 this requires a custom engine, in 5.2 theoretically it will not).
> 
> With all of this in place, I had to write a virtual \`PlayerController-\>SetShowMouseCursor\` (which itself is not virtual, so another engine hack required) and any time I want to show or hide the mouse in my extended \`SetShowMouseCursor\` I also explicitly call my (hacked to be public) overridden Action Router \`ApplyUIInputConfig\` with the appropriate config for a visible mouse (or invisible as the case may now be).
> 
> For all of this to work, the HUD and the C++ need to agree that the appropriate Input Mode is \`All\` (Game+Menu). And the mouse capture in my case was \`CapturePermanently\_IncludingInitialMouseDown\` with an invisible mouse, and \`CaptureDuringMouseDown\` with a visible mouse.
> 
> Furthermore, since I use the mouse for Look input, I disable Look when the mouse cursor is visible, though Move is still active.
> 
> \---
> 
> Additional reading related to \`Game\` capture and mouse weirdness:
> 
> https://forums.unrealengine.com/t/why-axis-value-of-moveforward-event-is-0-when-left-mouse-button-event/577686/5?u=xi57

---

<div class="post-metadata">

**Author:** ![Nique](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nique](https://forums.unrealengine.com/u/Nique)\
**Post date:** [February 2, 2024, 11:25pm UTC](https://forums.unrealengine.com/t/how-to-show-mouse-cursor-without-losing-mouse-capture/578191/8 "2024-02-02T23:25:06Z")

</div>

Not sure if you (or others) are looking for this, but in 5.3, I managed to solve this by explicitly set the input mode for game and ui.

 ![Screenshot 2024-02-03 004117](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/0/c/20c420cbfbbb66655cb4bc761e8ee750a6a556f3.png)

I enabled the mouse ‘the old way’ and unchecked hide cursor during capture.

I configured chorded actions

- Middle mouse button + mouse X = spin
- Middle mouse button + mouse y = tilt

I created a mouse cursor in common ui, and add it as default mouse cursor in game project.

![ezgif-3-7f4d2de178](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/2/f/a2f6917b35e56aeb157cd447fb1a0213fd52be30.gif)

As you can see, I now have a mouse cursor, and I also have capture for some reason 😉

---

<div class="post-metadata">

**Author:** ![baobao4435](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/baobao4435/32/950790_2.png) [@baobao4435](https://forums.unrealengine.com/u/baobao4435)\
**Post date:** [February 2, 2024, 11:29pm UTC](https://forums.unrealengine.com/t/how-to-show-mouse-cursor-without-losing-mouse-capture/578191/9 "2024-02-02T23:29:54Z")

</div>

I met this problem,and I didn’t resolve it.  
So I just check if the mouse position close to the screen edge.  
If mouse is at the edge I’ll add a constant movement to the camera.

---

<div class="post-metadata">

**Author:** ![xi57](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/xi57/32/1194660_2.png) [@xi57](https://forums.unrealengine.com/u/xi57)\
**Post date:** [February 4, 2024, 3:36pm UTC](https://forums.unrealengine.com/t/how-to-show-mouse-cursor-without-losing-mouse-capture/578191/10 "2024-02-04T15:36:02Z")

</div>

Your solution does indeed work for some use cases.

The solution that I posted is a bit more involved, and will work in 100% of use cases. For more details see the tutorial request link, it contains the entire problem set and a link to a blog explaining some of the edge cases as well as a video demonstrating some of the other related problems and how to fix them.

If your solution works perfectly for your game, there is no reason to make it any more complex. However if you notice that it’s not working the way you want, then you’ll want to look at my solution for the fix. (TLDR showing and hiding the mouse repeatedly will forcefully recenter the mouse due to CommonUI, and my solution is required to fix that).

Hopefully Epic provides more configurability to CommonUI in subsequent versions but as of 5.3 my solution is the only way to truly control the mouse.

---

<div class="post-metadata">

**Author:** ![Perfect\_Human\_Interface](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Perfect\_Human\_Interface](https://forums.unrealengine.com/u/Perfect_Human_Interface)\
**Post date:** [April 18, 2024, 10:38am UTC](https://forums.unrealengine.com/t/how-to-show-mouse-cursor-without-losing-mouse-capture/578191/11 "2024-04-18T10:38:28Z")

</div>

Hello, in your writeup you mentioned

> This means any time I want to show/hide the mouse as a part of normal game play I need to explicitly manage the input mode and mouse capture settings every time the mouse visibility changes.

Does this suggest it’s possible to force on input mode/mouse capture after setting the mouse visible without the overrides and rewrites you described? I ask because I’m a beginner to programming with UE and using blueprint and this solution is a bit beyond me. I hoped to simply be able capture the mouse input values inside my mouse-controlled pause menu. I’ve tried as much as I could think of with no luck.

---

<div class="post-metadata">

**Author:** ![xi57](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/xi57/32/1194660_2.png) [@xi57](https://forums.unrealengine.com/u/xi57)\
**Post date:** [May 1, 2024, 3:42pm UTC](https://forums.unrealengine.com/t/how-to-show-mouse-cursor-without-losing-mouse-capture/578191/12 "2024-05-01T15:42:19Z")

</div>

The answer is entirely dependent on the type of game you’re making and whether or not you are based on Lyra. If you’re making a shooter based on Lyra, it’s fairly easy. In any other case, it requires a fair amount of non-intuitive-and-not-well-documented C++.

---

<div class="post-metadata">

**Author:** ![Zaglah](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Zaglah](https://forums.unrealengine.com/u/Zaglah)\
**Post date:** [April 28, 2025, 5:07am UTC](https://forums.unrealengine.com/t/how-to-show-mouse-cursor-without-losing-mouse-capture/578191/13 "2025-04-28T05:07:48Z")

</div>

Thanks 3 years later.
