When I tried loading the in game menu using the action key multiple times, the widget would keep layering on the previous one. Nasty!
This can be prevented by separating the function that sets up the widget from the function that loads the widget, and calling the setup function separately in code. Also, a boolean is set when the widget is shown. The widget should be loaded once, preferably in BeginPlay (store a reference to the widget - return the widget pointer inside the loading function), and conditionally showing or hiding the widget when triggered by the keyboard event.
I did this in C++, here’s my repo.
As an added quirk, this also allows toggling the widget using the keyboard alone.
@sampattuzzi thanks for your response!
P.S. I don’t think the keyboard binding should be shifted to the player character/controller’s InputComponent cuz it kinda breaks separation of concerns.