Enhanced Input actions are cancelled by clicking a button widget

I am very new to Unreal, but I have encountered a weird problem regarding enhanced input and clicking on widgets.

My game uses third-person controls together with mouse input so that I can click on objects and their menus.

However, when I press at least two keys together, for example “W” and “A” in order to walk diagonally, and then I press a button widget, then the first key input gets cancelled.

This is kinda tough to explain, so I have made a quick demonstration GIF:

help

It is important to note that once I start walking, I am keeping the “W” and “A” keys pressed constantly, however once I press the button in the top left, the character stops walking to the right, completely ignoring this input until it is released and pressed again.

I have only added three things to the Third Person sample project:

  1. Enabled mouse cursor and mouse events in the Third-person Character Blueprint
  2. Added a simple Widget Blueprint with a Button & some text, along with a click event that prints “Hello” and then removes the button
  3. Added a simple Actor that creates the button widget when it is clicked

Below are some screenshots of the blueprints:



This is technically a duplicate of Pressing widget button with mouse click lose keyboard Enhanced input. , but it wasn’t resolved there and I feel like since I am adding a lot more information this new post is hopefully justified. However if I should post this stuff on that thread then I will do so.

I can’t help you because I too am trying to learn the deep knowledge of the Input/Widget magic. I’ve been working on my game for over a year without apply the correct methods for UI handling. It has caught up with me now, and my web of hacks is not easy to debug.
I just wanted to vent to someone and your post is the unlucky one.
Cheers.

Could try this, it worked for me.

In the project settings, uncheck “Should Flush Pressed Keys on Viewport Focus Lost”

Yeah, having exactly the same behavior… Can’t find a solution yet, tried what the last person suggested with no changes.

Seeing as some people replied here, I did come up with a janky work around “solution”.

  1. I added a boolean variable to check whether the mouse is on the button or not, and change it accordingly using the Mouse Enter/Leave Events

  2. Then I added a new Enhanced Action for listening to Left clicks (or whatever click you want to activate the button). If the “Highlighted” variable is true, then some event that emulates “OnClicked” is called.

  3. One last thing that must be accounted for, is that if you use “On Mouse Leave” for anything else, then you need to catch whether the Mouse Button is down, since clicking on a widget always calls “On Mouse Leave” for some reason

I am sure the fancy stuff like changing colour can be done relatively easy with the Mouse Enter/Leave Events as well, but I didn’t bother.
This might cause some issues down the line like not being able to have multiple buttons in one widget, but at least this way Enhanced Input Actions are not cancelled.

You’re a godsent! I’ve been struggling on this for days.
Thanks!