# Disable mouse input when over widget

**URL:** <https://forums.unrealengine.com/t/disable-mouse-input-when-over-widget/490719>\
**Category:** UI\
**Tags:** Input, unreal-engine, Widget, question\
**Created:** [November 8, 2021, 3:30pm UTC](https://forums.unrealengine.com/t/disable-mouse-input-when-over-widget/490719 "2021-11-08T15:30:23Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![meinhold](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@meinhold](https://forums.unrealengine.com/u/meinhold)\
**Post date:** [November 8, 2021, 3:30pm UTC](https://forums.unrealengine.com/t/disable-mouse-input-when-over-widget/490719/1 "2021-11-08T15:30:23Z")

</div>

Hello,

unreal newbie here!I I try create Third Person RPG with WoWlike control. Now when i dont hold any button i have normal mouse cursor. When i hold left button and move mouse cursor is hidden and camera rotate around player. When right button is hold and move with mouse cursor is hidden and player character rotate. This work fine but if i try add a widget like action bar my problem pops up.

I want disable mouse input when mouse cursor is over the action bar so character or camera dont rotate when hold mouse button and move with mouse.

I try use on mouse enter \> set input to UI only and when mouse leave \> set input to Game and UI but now when my mouse is over actionbar a havnt keyboard input so i cant run etc.

I try use boolen for mouse enter and leave but when mouse is over the widget and i press mouse button boolen is set to leave.

Can someone help me please?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [November 8, 2021, 7:07pm UTC](https://forums.unrealengine.com/t/disable-mouse-input-when-over-widget/490719/2 "2021-11-08T19:07:32Z")

</div>

In the widget, override `onMouseDown`, check if it’s RMB and then pass _Handled_. This way the widgets will consume RMB input and the PC will be unable to detect it.

---

<div class="post-metadata">

**Author:** ![meinhold](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@meinhold](https://forums.unrealengine.com/u/meinhold)\
**Post date:** [November 9, 2021, 1:48pm UTC](https://forums.unrealengine.com/t/disable-mouse-input-when-over-widget/490719/3 "2021-11-09T13:48:37Z")

</div>

Thanks You very MUCH!!! I add this function to onMouseUp and double click too. Works pretty well.

---

<div class="post-metadata">

**Author:** ![wyd111](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@wyd111](https://forums.unrealengine.com/u/wyd111)\
**Post date:** [April 18, 2022, 3:51am UTC](https://forums.unrealengine.com/t/disable-mouse-input-when-over-widget/490719/4 "2022-04-18T03:51:58Z")

</div>

hellow, you can create a blank widget and set CanvasPanel Visibility = Visible and add to viewport, to block all click event . But you must have to create some event to remove this blank widget befor you want to use mouse event

---

<div class="post-metadata">

**Author:** ![DEICIDER78](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deicider78/32/1006174_2.png) [@DEICIDER78](https://forums.unrealengine.com/u/DEICIDER78)\
**Post date:** [June 29, 2024, 7:49am UTC](https://forums.unrealengine.com/t/disable-mouse-input-when-over-widget/490719/5 "2024-06-29T07:49:52Z")

</div>

Hi, I figured out how to create the MouseDown override function but I can’t check if RMB and switch it to Handled, can you help me?  
I’m using UE 5.4.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 29, 2024, 7:58am UTC](https://forums.unrealengine.com/t/disable-mouse-input-when-over-widget/490719/6 "2024-06-29T07:58:38Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/2/4/62418f5d3210700ff0e5949a227fe43e9f840fbb.png)

---

<div class="post-metadata">

**Author:** ![DEICIDER78](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deicider78/32/1006174_2.png) [@DEICIDER78](https://forums.unrealengine.com/u/DEICIDER78)\
**Post date:** [June 29, 2024, 8:13am UTC](https://forums.unrealengine.com/t/disable-mouse-input-when-over-widget/490719/7 "2024-06-29T08:13:55Z")

</div>

Thanks for your reply.  
I followed your example but the click remains.  
I’ll try to explain better, I’m trying to make a terminal with a widget on which you can only write commands and I don’t want that when you click with the mouse this eliminates the focus from the editable text.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 29, 2024, 8:19am UTC](https://forums.unrealengine.com/t/disable-mouse-input-when-over-widget/490719/8 "2024-06-29T08:19:44Z")

</div>

Set Focus to the Editable Text when the user clicks anywhere on the widget.

---

<div class="post-metadata">

**Author:** ![DEICIDER78](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deicider78/32/1006174_2.png) [@DEICIDER78](https://forums.unrealengine.com/u/DEICIDER78)\
**Post date:** [June 29, 2024, 8:30am UTC](https://forums.unrealengine.com/t/disable-mouse-input-when-over-widget/490719/9 "2024-06-29T08:30:55Z")

</div>

Yes, I had already tried (as per the image) but when I do the BTN Down it always loses focus on the editable text… I really feel like a loser 😭

 ![Screenshot 2024-06-29 102417](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/8/3/08311f88d3e3172de8c25002be9fe96debedbf78.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 29, 2024, 8:37am UTC](https://forums.unrealengine.com/t/disable-mouse-input-when-over-widget/490719/10 "2024-06-29T08:37:30Z")

</div>

I just tested this and it works fine. I can click outside the editable text (but still on the widget) and keep typing as if nothing happened. If you want to click outside the widget (on the viewport) and still keep focus, then you’d need extra steps:

- either use `UI Only` input mode
- or override `onFocusLost` and restore back to the `Editable Text`.

* * *

- your current script returns defaults (false branch) when you click with something else than LMB, though - not sure if this is desired, the previous description was unclear:

> I don’t want that when you click with the mouse this eliminates the focus from the editable text

If you want **every** mouse button to be consumed and redirect focus to the `Editable Text`:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/a/b/5ab767502d3ed8fe0a671e92bbc63df72de9d9b7.png)

- ensure the widgets you’re clicking are visible so they can consume input (`handle` it)
- spamming mouse buttons will trigger **double-click** , it also needs to be handled:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/0/d/80d9af3087589245558a73d8e3921e9badc7a031.png)

---

<div class="post-metadata">

**Author:** ![DEICIDER78](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deicider78/32/1006174_2.png) [@DEICIDER78](https://forums.unrealengine.com/u/DEICIDER78)\
**Post date:** [June 29, 2024, 3:13pm UTC](https://forums.unrealengine.com/t/disable-mouse-input-when-over-widget/490719/11 "2024-06-29T15:13:00Z")

</div>

It doesn’t work for me because to make the mouse pointer disappear in my begin play I inserted “set input mode game only” and set the variable “show mouse cursor” to off, if I remove the “set input mode game only” it works but you can see the mouse cursor which I don’t want… any ideas?

If I use “set cursor” to “none” the mouse disappears but if you move over it the editable text reappears.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 29, 2024, 4:38pm UTC](https://forums.unrealengine.com/t/disable-mouse-input-when-over-widget/490719/12 "2024-06-29T16:38:37Z")

</div>

Game Mode only, so… what did you really expect - the ask makes no sense whatsoever - you’re just using the engine _wrong_ 😇 . It’s quite normal to juggle input modes as needed. Alternatively you can tap into Enhanced Input and priorities but, just don’t use Game Only mode when you do not mean Game Only.

Good luck!

* * *

Btw, each widget can control cursor visibility with a lot granularity. If you want to use UI, do not switch to a non-UI input mode…

---

<div class="post-metadata">

**Author:** ![Futurristic09](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Futurristic09](https://forums.unrealengine.com/u/Futurristic09)\
**Post date:** [May 8, 2026, 6:05am UTC](https://forums.unrealengine.com/t/disable-mouse-input-when-over-widget/490719/13 "2026-05-08T06:05:10Z")

</div>

Worked for me thanks 🙂
