UMG SetUserFocus() flushes input causing inaccurate release events


We have a custom UserWidget that is called a UIScene that sets focus to a default widget upon being added to the player’s viewport.

We have a case where on an InputAction Pressed event we add a UIScene to the player’s viewport. This is all fine and good

However, for this case we want to remove the UIScene from the viewport on InputAction::Released. This is where the problem comes in.

In the scene’s NativeOnInitialized (also tried in blueprints as well, same result) I ListenForInputAction(“TheInputAction”, IE_Released, true, MyFunction).

The Problem: MyFunction gets called immediately as soon as DefaultWidget.SetUserFocus() gets called. I’ve tried this in code and blueprints. To confirm it, I added a 5 second delay before I call SetUserFocus() and as soon as the delay is up the Released Event gets called (even though I have the input button held down). If I let go of the button I get the Released Event again. So with logging it looks like

Hold Right Shoulder → Open UI → Set Default Focus->Released Event->Sometime later release right shoulder->Released Event
This happens on mouse/keyboard as well as gamepad.

So to get around this I just count the number of times the released event happens and ignore the first one. Which was annoying but fine. Until we started testing on the split screen player.

The Splitscreen Player does not have this issue and behaves as expected. So on the splitscreen player the UI would stay open after releasing the InputAction button because it’s waiting on another release event.

My super hack is to check which controller id the player is and do the counting hack or not. This is not ideal. I’ve been debugging and I’m not making any headway. I’ve traced through the SetUserFocus() code the best I can and I"m not seeing anything about any input flushing or anything like that. But yet in PlayerInput::ProcessInputStack() it says my InputAction key is no longer down. But on the next tick it is.

Its like something is setting the keystate of the held button on focus changes.

Any ideas on what is causing this?