Bug in 4.8 Problem removing widget from parent in any keypress type event

In 4.7 I had a widget with an OnKeyDown override (escape key) that I used to close my widget by calling Remove from Parent node. In 4.8 this no longer works as it seems to somehow disconnect the player controller from input. You can duplicate this simply by creating a brand new 4.8 project (I used third person template), create a new widget and add it to viewport. In the widget override OnKeyDown (or any other keypress function) and in the override just call Remove from Parent and return node. It will remove the widget but you will no longer be able to control the character.

Hello ,

I was unable to reproduce this issue on our end. I have a few questions for you that will help narrow down what issue it is exactly that you are experiencing.

Quick questions:

  1. Could you provide a screen shot of the blueprints used?
  2. I just placed a remove form parent node within the On Key Down override, did you do anything else?
  3. Could you give the exact steps used to reproduce this issue in a clean project?
  4. When you say that you loose control of the character to you mean that your movement controls no longer work?

Hello Rudy,

First just create a new 4.8 blueprint project based on the Third Person template.
Then create a new UMG Widget and override OnKeyDown as follows.

Inside the ThirdPersonCharacter add code to display the blueprint as follows.

Once you start the game you can press 1 to display the widget.
Then press any key and you will lose control of the character.
I suspect it has something to do with the Set Input Mode UIOnly node.

Thanks for your quick response!

Hello ,

I was able to reproduce the results that you are seeing on our end. This appears to be working as intended. You would be correct in assuming that your issue comes from the “Set Input Mode UIOnly” node. You will need to be sure to set the input mode back to the game or the game and the UI to prevent this from occurring.

Make it a great day

Rudy - This is still not working correctly. Setting input mode to game only, or to game and ui does not resolve the issue. I get the exact same results every time. I have tried resetting the input both before and after the remove from parent and in either case I lose control of the player…

Hello ,

This is an issue with work flow. Could you tell me exactly what it is that you are trying to accomplish?

Hello Rudy,

I am trying to remove a widget (my game menu) by pressing the escape key (or any other key). When I show the widget I need to be in UI mode only. When I close the widget I need to return to the game and be able to control my player.

In 4.7.6 I am detecting the escape key via the OnKeyDown event - then I call the remove from parent node, and then call the set input to Game only node. This works just fine in 4.7.6 but in 4.8 this no longer works.

The steps I’ve provided show how to repro this issue in the most minimal way. Ultimately, closing a widget from a keypress should not cause you to lose control of your character, so something is not working correctly. However if this is not the correct workflow can you please advise on what is?

Thanks

Hello ,

Using the existing setup as much as possible this is how I have gotten your project to work. I hope that this helps.

Example:

Here I added a Show mouse cursor and set it to true. This will keep the mouse from being captured while your widget is up.

I added an Event Destruct to the event graph. This calls a set input mode when the widget is removed from the parent. It will also hide the mouse.

I made no changes to the on key down event. I included this so that you could see the whole setup.

46641-mouseonlywidgethelp3.png

Make it a great day

UPDATE:

Rudy - I hate changing the parameters like this but here goes:

The good news is that I’ve discovered my issue. There are two parts. The reason I was not regaining control of my character is because I was using the 1 key to close the menu. The 1 key is bound in the controller to show the menu. So I added the Handled to the return. This did not fix the issue, but I did determine that if I use PreviewKey or OnChar with handled then it works great.

I am currently happy to use either of those methods, but I do think that you have an issue with OnKeyDown not passing the Handled response up the chain like the other two events do. Thanks for you time and help with this.