How to make UMG block left and right clicks

Buttons, text boxes, etc. will prevent the events from firing but nothing else. Widgets have the Visibility setting but this doesn’t seem to affect anything besides the widgets that already block the mouse.
I’ve tried Google but can’t find a solution.

So how can a make a panel or image block mouse input? Surely this is possible.

Does no one have any ideas on this?

if its visible it should block mouseclicks. hit test invisible would be that it appears on screen but clicks go through

It only seems to work with widgets that are already interactive such as buttons and text boxes.
A button will prevent left click events from firing, but not right clicks. A text box will consume both left and right clicks.
But panels, images, etc. don’t do anything no matter what I set Visibility to.

you want them just to block the clicks or you want something to happen after you clicked an image etc. ?

I simply want it to block left and right clicks.
The left and right mouse buttons are used to interact with actors in the level, and obviously certain parts of the HUD should block that interaction otherwise the player won’t be able to see what they are clicking on.

So it seems like this is not possible? The visibility setting seems like it should do this, but it doesn’t.
This is a really basic feature, surely I’m not the first person that needed this.

I’ve now found that the visibility setting only affects widgets. So a widget set to “Visible” will block interaction with other widgets behind it, but won’t prevent mouse input events from firing in the player controller for example.

So since UMG can’t automatically consume mouse clicks, is there some way to check if the mouse is over a specific widget?
This way, in the player’s mouse down event, before performing the line trace I could first check if any part of the hud widget is blocking the mouse.

Visibility controls hit testing. Once you’ve been hit tested you need to decide what to do with it. To say - block mouse up/down you need to override OnMouseDown and OnMouseUp and return Handled, similar solution for Keys, same for MouseWheel…etc. Everything you want to block just override the event and return handled that will prevent it bubbling up to the viewport where it will be then sent to the player input system.

But where do I override OnMouseDown and OnMouseUp?

In the UserWidget you want to make that can consume mouse clicks head to the Graph view,

My Blueprint (Tab) > Functions > Override > On Mouse Button Down/Up

1 Like

If you want to block input to widget, you can try something like: place image to whole screen, set image to transparent (alpha 0) and visibility to “hit test visible” or something like that, and you can then switch between “hit test invisible” and “hit test visible” that image in widget blueprint…

Override: In widget blueprint, you have at left side “functions” and something in brackets like (“33 overridables”), hover mouse over this text, click and you will get dropdown menu…

Thanks guys, this is exactly what I was looking for.

For various reasons (due to already having a quite complicated UI setup), this advice wouldn’t work for me. However, for anyone who wants a very simple way of blocking UI input… Just put on a button which covers the extent you want the input blocked, and make its various styles have an alpha of 0, and voila! Probably a dirty hack, but it did the job for me! :slight_smile:

For others.

this is works for me to prevent mouse input on my custom skill use button.

if u return FReply::Handled() the mouse click will work on your widget.