BP - Set Input Mode UI Only

Hello all - i got a problem with a pause mode using SetInputMode-UIOnly blueprint node… when i do this i can use the mouse but the keyboard becomes unusable… while i am fine with using buttons to click on - this presents a big problem when it comes to things like:

Pausing the game & reentering with the Escape Key for example (how most games do this… i’m debugging PIE mode with M key)
Ingame actions menus that require keypress - but you dont want movement out of the keys - think Starcraft, or any other iso action game where you build stuff with hotkeys and the same keys maybe bound to axes.

Here’s a screenshot of how i’m doing this - i’ve read up on it quite a bit and have come across many UE4 forum posts about the same topic - but with different answer approaches… none of which seem to work.

I’ve tried:
Setting keyboard focus - does nothing apparently
Binding keypresses in the UMG Widget is frowned upon from other dev’s - they say to keep it in action inputs mappings
unposses/reposses pawn - this works but in a multiplayer/networking game i’m jacked…

Screenshot:

Hi, you need to override the Keydown event within the widget “MyHud” to do that select the On Key Down option in the Override drop down next to Functions as in this capture:

75468-1.jpg

You will get a new function set your nodes as this example trap the G key to close the widget and return the control to the game with “Set Input Mode Game Only” node.

Hope it helps.

Regards.

1 Like

This works and is what i was left to do - however there are alot of dev’s that shun on this tactic to pull this off… but i’ll test the heck out of it and see if i have any bugs - which i dont presume I will.

weirdly, I can’t get it to respond to any key presses whether I override On Key Down or not. I’m not even setting the input to UI only. The widget is playing an animation and it’s set up to remove itself at the end of the animation by calling an event on itself that removes it from parent. But I can’t get it to print string let alone call that function to remove it.

Heya, if this worked for you can you mark as answered? Thanks.