Close menu with same button as opening

Not stupid at all, actually. It’s just an input processing thing.

Set Input Mode UI Only prevents the Player Controller from processing input - pressing M while this mode is active does nothing, the PC ignores it, as instructed. The input is processed in the widget instead since we’ve given it to the UI exclusively - Set Input Mode UI Only

You can have it processed by both (widgets go first, though) with Set Input Mode Game and UI node but if you’re making a first person shooter kind of game (we don’t know it here) you may not want to do this.

In order to make the same key work seamlessly (the way I think you want it to work,) you’ll need the following:

In the player (or wherever you press M to open the menu):

  • the above either creates or shows the widget, it does not close it
  • the below is processed in the widget - this closes the menu:

  • the override is here:

  • and you need to make the widget keyboard focusable:

343184-screenshot-2.png

4 Likes