As you may know, the player controller has not a clue what is going on when you set input mode to UI only.
You generally handle a scenario like this by detecting input that dismisses the widget in the widget itself - onKeyDown with isFocusable flag set to True.
the Player Controller shows / adds the widget, switch to UI Only
the widget switches to Game and UI and then hides / removes itself.
I’m using a flip flop node to open and close a widget through a controller blueprint. It is possible for the widget to be closed when ever I have it set to Set Input Mode Game and UI. But if I were to replace Set Input Mode Game and UI with Set Input mode UI Only, then it would not let me close the widget and just only let me open when pressing a key. But after that, unable to close, leaving the widget open.
The reason on why I want to set the widget to Set Input mode UI only is so then the player wont move in the background when ever an arrow key is pressed.
I know there’s an alternate way with Set Game Paused. But I prefer to avoid this route due to me wanting the background to move in real-time while widget is displayed. I would appreciate any help, Thanks.
The Player Controller handles the cursor when it’s not on over UMG and vice versa - the widgets take over cursor when a Visible widget is underneath. If no Visible widgets are present, the control is passed to the Player Controller.
hide cursor as soon as widget is set
to Set Input mode UI Only
get Player Controller → Show Mouse Cursor to False
if you have Visible widgets, each of them will need to:
Don’t forget to tell the root of the widget how to treat the cursor in case the root is set to Visible.
I have seen the use of Is Valid when dealing with UI’s toggling on and off. Found it to be effective.
Side question. In a scenario where you have multiple widgets loaded up, what happens if you use the Set Input Mode to UI Only, and you do not connect the pin “In widget to focus” to anything?
Does the focus stay on the very first widget loaded or perhaps the last widget that had focus ?