Play event after key sequence

Hi everyone,

I tried to figure this out for about half a day now without getting any closer to a solution, so I ask you guys now.

This is the situation: I want to create an exit menu, which allows you to leave the game/close it. But it shall only work by keyboard input. So I got the idea to create a widget which shows the text “press enter to leave” in the game screen and let it open up by pressing esc. Works fine so far. But now I need to tell the game that if I press enter now, it shall close the game. But the enter button only is supposed to close the game, if I pressed esc before and opened my warning/widget asking if I really want to leave.

So how do I tell the enter key to only close the game if I had pressed escape before?

Thanks a lot!

A little confusing on the setup, but If i understood:

You want to hit “Esc” to bring a message box “Really want to Leave?” and then on there you want to check for pressing Enter to exit?

Exactly. Sorry for the bad explanation. It has been a long day :smiley:

Then I would do the following setup for as an example,

  1. Setup and Input Key for your PlayerController blueprint for the “Escape” key.

  2. When the Escape Key is pressed, turn on your warning/confirmation button, make sure to “SetFocus” to the widget, and Set Input Mode to UI Only.

  3. In your widget, check for the KeyDown event for the “Enter” key.

From there exit the game.

UMG and button mapping is still something the devs want to improve on but for now thats a way to do it.
Hope that helps =)

Hey there, the Noob is back :wink:

First of all, thank you for your answer!

I tried to do what you told me, but I just couldn’t get it to work. Propably my fault.
I worked in the level blueprint to get the warning opened if Esc is pressed. Therefore, I used this simple setup:

Now comes the hard part (or the part, that’s hard to ME). First of all, I don’t really know, where in this Node-hierachy I should add the “Set Focus” and the “Set Input Mode to UI Only”-node. I experimented with different setups using the Set Input Mode to UI Only-node, but could not achieve anything.

The “Set Focus”-node was very interesting. I couldn’t even really find it :smiley: . As I said, probably I am doing something HORRIBLE easy HORRIBLE wrong, but I just don’t know what. I experimented with these two nodes, but did not get any further:

I think I understood step 3 and why to use such a setup. If the “Enter”-button could be connected to “Quit Game” in the widget itself, “enter” would just quit the game if I opened the widget by pressing Esc before, am I right?
But unfortunately, that doesn’t mean I could build it :smiley:
I tried to go into my widget and create a “Tab”-node (which could not be found in the widgets graph search). Also, I couldn’t find an accurate alternative. I was hoping for a “KeyDown”-node, but this also lead to no results. This really makes me feel stupid.

I assume that all these problems just appear because I am to stupid to understand UE or your explanation. Maybe you are in front of your PC now thinking “What an idiot”, and in this case you even might be right (concerning UE) :wink:
But I ask you to give me a more detailled explanation and maybe show me where I and my thoughts went wrong.
Thanks a lot!