Download

How do you add keyboard input in UMG?

I’ve been searching for a solution for days, and no answer. I’m just wondering if it’s possible to add keyboard input in UMG? In the graph, there is no option for keyboard keys, and you also can’t use the action or axis buttons, either. I’ve been trying to get certain things to work, mainly a menu, but not being able to have input in the UMG graphs is extremely limiting.

In most tutorials I’ve seen, in menu building for example, they only show how to make buttons and add functionality to the buttons, like a pause menu. They show how to create the buttons for the menu, like Continue, Exit Game, Return to Main Menu. And to use these buttons you always have to use the mouse to click on them. Why can’t you use the keyboard for these same functions, scroll up and down using the arrow keys.

Like a recent tutorial I watched showed how to set up Continue and Exit Game buttons, and in the graph it was something like “OnClicked(exitbutton)-> execute console command “exit”” and OnClicked(ContinueButton)->blahblah. Why instead of onclicked events, can’t I use the action mapping I set up?

Also, another complaint, as to why there are no tutorials for more complex menus/inventories, e.g. with multiple tabs. I want to learn how to make a real menu with different tabs like equipment, status, skills, etc, and when you click or press on one, a new screen opens up. The tutorials available now are way too basic.

I suppose what you could try and do is to use Events. So when the button is pressed, an event is fired that the UMG listens for and does whatever it is it needs to do.

UMG doesnt work with the action mappings… at least not yet. There’s no way I could find to set an action mapping (Project Settings → Input) and be able to access the event from a widget blueprint.

I’m not ecstatic about this solution, but it works. Gotta create a custom event in your UMG widget, and listen for it all the time. Stick all your code behind a branch that checks for the button press, so that it’s only running when the button is pressed. A DoOnce node might be helpful too, depending on your situation.

UMGkeybind.jpg

Yeah so, essentially what I said. Tick might be overkill though. Pretty sure that you can make Events and Listeners like in C# can’t you?

Probably, but I can’t say I know of an Event Listener node for Blueprints.

I suppose a better solution would be to use the standard action mapping, and then use an Event Dispatcher node bound to that keypress event.

In your UMG widget event blueprint move your mouse cursor here:
inputeventoverride.jpg

Override button will appear under cursor. Press it and select On Key Down from the list. On Key Down function override will be added. From there you can do something like this:
0d56d32caf2379585ff0bf73ff5d05eafd25d878.jpeg
An issue with this is that your widget must have focus for the event to work.

I guess another option would be to set your input mode to Game and UI and use input events from your character.

What is “focus”?

You can lay out the template?

Checkout my answer to this question on AndwerHub

https://answers.unrealengine.com/questions/142832/umg-keyboard-shortcuts.html

Another Way to avoid Pause game to receive user input is using Set Global Time Dilatation = 0. This is not a pause, but works like that. So this can receive the input of character in a “paused” game.