Switching between Input mode Game only and Input mode UI only

Hi! I waned to show menu tab when I press escape key and when I press escape key again, then back to game. It works but I should click on menu to focus on menu and click on game to switch to game. and this is the blueprint.

So I used Input mode UI only and Input mode game only, It doesn’t close menu tab anymore.

Help?

When you set input to UI Only, the Player Controller can no longer process input - that’s why the FlipFlop won’t fire again. The widget in focus has now the exclusivity and it should be the widget that shuts itself down and restores the appropriate input mode. Consider the following:

Player Controller

  • opening the menu

Widget

  • widget overrides onKeyDown (check the dropdown menu on the far left)
  • give the controller its input processing capability back
  • removes itself from the viewport

4 Likes

It works but I should click on menu to
focus on menu and click on game to
switch to game.

Also, explore this:

You can grant widgets focus and even make them keyboard focusable. This becomes indispensable when you open a menu and want to start typing straightaway rather than painstakingly attempt to select a field to type in.

2 Likes

Thank you! It works now.

@Everynone
I tried following your solution but I can’t get it to work.


I can open the widget, but after that, no input is registered in-game.

This is the code I use to test if any key was registered.

BTW I don’t have a custom player controller, I rely on the one that is created automaticly.

1 Like

You gave full control to the widget via UI only mode - this means the controller is not processing input anymore and we can’t have it involved in this scenario. It simply no longer knows what is going on with the keys and would always return False here.


Instead of the controller, compare == the Get Key to what is needed here.

Also, ensure the widget is keyboard focusable.

1 Like

Thanks, it now handles the key inputs and can close the widget, but now how do I return the player controller to the character? After exiting the widget now is the character that does not respond.

1 Like

I found the error, changing the Input mode changes the Mouse Capture Mode so it wasn’t behaving as I expected. Using “Set Mouse Capture Method” to Capture permanently including initial solves it.

1 Like