Disable mouse input when over widget

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?

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.

5 Likes

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

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

1 Like

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.

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.

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

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 :sob:

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:

  • 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:

1 Like

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.

Game Mode only, so… what did you really expect - the ask makes no sense whatsoever - you’re just using the engine wrong :innocent: . 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…