Download

UserWidgets and ActionInput (keybinding)

I already asked on the AnswerHUB but unfortunately nobody answered my question there. So I try getting an answer in the forums. I am on engine version 4.14.

I use keybinding for opening different user widgets (e.g. inventory, map). I plan to allow the player to change the bindings so he can use whatever key he likes. For opening the widget that is just fine because one can use the ActionInput event for this. I would like to close the widget with exactly the same key but you can not listen to the ActionInput event from a user widget so I have to hardcode the key for closing. That means if I choose ‘i’ for the inventory and the player changes this to ‘tab’, the inventory opens up on ‘tab’ and closes on ‘i’.

Is there any way to reference the keybindings from within an user widget?

I have a setup that looks like this:


While it is currently a static key, changing it to an action input would be simple.

If you still really want to ‘listen’ for inputs in your widget, there is a work around.
Listening for input inside your widget would look like this pseudo code:
(widget)
ActionInput -> execute function / blueprint setup.
So if you instead add an event that does this:
(widget)
Custom Event -> execute function / blueprint setup.
And now from your player controller, you put the actioninput, get the reference to the widget and execute the custom event.
(player controller)
Action input -> custom event of widget.