Close UMG with key defined in Input mappings.
I've search around a lot but couldn't find a real, up to date, answer so here I am.
I'm working on my inventory / menu system. I defined a key in Project Settings -> Input called "Toggle Inventory" and mapped to both spacebar and my controller start key.
I have the usual code in PlayerController to add the UMG to viewport, pause the game and switch to UI only input when the "Toggle Inventory" key is pressed:
The issue is... how do I go back ? I do know about the "KeyDown" event that can be overriden in UMGs, but you can't use the keys defined in Project Settings -> Input, you have to hard code the keys used..
I want my user to be able to customise that key later down the road, so hard coding is not an option.
A lot of old answers say to trick the system by leaving the InputMode at "Game and UI" and use the PlayerController to go back... that seems uggly.
Any up-to-date idea / tips ?
asked May 14 '16 at 01:42 AM in Blueprint Scripting
In UMG Widgets there is a function called ListenForInputAction: https://docs.unrealengine.com/latest/INT/API/Runtime/UMG/Blueprint/UUserWidget/ListenForInputAction/index.html
This function will allow you to bind any predefined action, hope that helps!
EDIT: Here is a screenshot of an example usage, just replace the Action Name with the name of your input action:
Yes, the idea of the other users is right.. you have to use the playercontroller to get the toggle inventory event to the umg.. its nasty. What might be possible is accessing the keybind information and use that knowledge to know what key press should trigger closing the umg.
A good place to start is probably looking at this code: https://forums.unrealengine.com/showthread.php?51449-Full-Project-Rama-s-UMG-Rebindable-Key-System-Rebind-keys-at-Runtime!
answered May 14 '16 at 08:17 AM
If you set to UIOnly, keyboard is disabled.
You have to set it in "InputAndUI" and disable input in your controller or character (I don't remember), this way the keyboard keeps sending keys, and the character won't move
answered May 14 '16 at 09:45 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here