When playing, the input to the UMG is not entered (OnKeyDown)
Press the mouse button to focus on the widget and press Input to enter OnKeyDown.
However, even though Widget has processed the Input (Consume), ViewClient on the Game side is also processed.
Through this test, i realized that even with SetInputGameAndUIMode, the starting focus is not Widget.
Second test: SetInputUIMode
When playing, the UMG will have an Input (OnKeyDown)
The Input of ViewClient is filtered and not operated by the check of the boolean.
And the question is,
Even though Input has been processed in Widget from SetInputGameAndUIMode, why is it descending to the ViewClient (PlayerController)? Can’t i stop this?
2) Is it only by calling SetInputUIMode to process the input of the UMG? What if multiple UIs try to open at the same time, and all UIs try to operate the input?
3) It is said in UE4 that if the input is Consumer in Widget, it does not go down to ViewClient. In UMG, there is no check to see if the input is actually Consume. Is there no way to do this?
Why does OnKeyDown enter the Widget only when you click on a button in the widget even though you are in SetGameAndUIMode? Can’t you get both sides right in when you start playing?
Even though Input has been
processed in Widget from
SetInputGameAndUIMode, why is it
descending to the ViewClient
(PlayerController)? Can’t i stop this?
In SetInputGameAndUIMode both Widgets and the Player Controller get a chance to process input with widgets receiving priority.
You can stop it be passing in Handled. This indicates that the input has been processed and will terminate to tunnel to other widgets that may be underneath and will not reach the Player Controller.
The Player Controller will not receive the call. The widget handled it, consuming the input. Passing Unhandled here, on the other hand, would process the input in the widget and in the controller.
2) Is it only by calling
SetInputUIMode to process the input of
the UMG?
No, for as long as the widget has Focus, it will try to process inputs - for mouse inputs there needs to be at least one Visible element present. For keyboard, the widget can be Hit Test Invisible but needs the isFocusable flag to be true.
What if multiple UIs try to
open at the same time, and all UIs try
to operate the input?
You can’t have 2 widgets in focus so keyboard input goes to the one with Focus. For mouse it will depend on Handled / Unhandled - whoever is higher in the Z order and is Visible gets to act first and can consume it or let it tunnel to any visible UI layer below, potentially reaching the controller.
It is said in UE4 that if the input
is Consumer in Widget, it does not go
down to ViewClient. In UMG, there is
no check to see if the input is
actually Consume. Is there no way to
do this?
Handled / Unhandled, as above.
Why does OnKeyDown enter the Widget only when you click on a button in the widget even though you are in SetGameAndUIMode?
Because the widget does not have focus yet, clicking a button shifts the focus onto the widget.
Can’t you get both sides right in when
you start playing?
You absolutely can - grant widget focus when it’s constructed:
When I click on the mouse or enter a key, No input is passed to GameLogic (PlayerController) even if no Widget is in AddToViewport. (maybe input will be just consumed)
if a Widget addToViewport, the widget will consume input.
If UI Mode is off, GameLogic(PlayerController) will be received input, even if widget is in AddToViewport.
tl;dr: Yes. Switching back to Game Mode input should be done in the widget since it’s the only entity processing input.
Let’s say you’re in the Game Mode input and press {M} (Player Controller) to open the Game Map and switch to UI Only Mode input. Now you can’t close the Map with {M} (Player Controller) because we switched to UI Mode.
The solution is to have the widget switch back to Game Mode. Essentially, make the widgets responsible for closing themselves.
Well, I see. You’re right.
If i switched from GameMode to UIMode, there’s no way get back to GameMode.
If UE4 is processing boolean variables for bIgnoreInput at the top of SlateApplication(the process of turning off the editor), if i do that, i might be able to process the input for both modes.
However there is currently a major bug in UE5 (be aware): If you set root Canvas to Visible, even if it by default stretched out to the Screen, it will let Clicks “go through”. Same happens with Borders. One must have non-transparency in order to take the click, and that means you will have to adapt your Game UI to this UMG Limitation. I am not sure, but I think, thats the reason why in many games Hit-Invisible Areas are actually blurred in order to prevent any Click Go Through.