I am making my pause menu UI with Common Activatable Widgets.
Whenever I pause the game and click anywhere outside of the pause menu, I lose my keyboard/gamepad focus from the button list and it never comes back until I close the pause menu and open again. This also happened when I was working with general Widgets before.
Mouse/keyboard/gamepad inputs are all valid in game stages, but I want the mouse input invalid while button widgets are on the screen. So far the game would accept the mouse click input when mouse cursor is either hidden or not, or click event is disabled.
How can I disable mouse input while menu widgets are on the screen?
(Mouse input should be valid only in game stages)
I searched for simple methods to do something similar to this and found these posts. Anyone who has better ideas, you are welcome to reply.
Hide Mouse
I found that the widget also affects cursor visibility, not only the player controller. This was why I couldn’t hide my mouse even if I used ‘player controller-set show mouse cursor’.
Easy fix! - losing UI focus on mouse click
This guy suggests to make a huge invisible button covering the entire screen. Whenever this is clicked, the ‘on-click’ event will make focus on the menu buttons again and prevent losing focus from the menu buttons. Clicking anywhere on the screen will lead to clicking the screen-sized button and trigger the ‘on-click’ event of it.
So I hid my mouse cursor from the widget blueprint’s panel settings, and made a screen-sized invisible button in order to force my focus on the menu buttons no matter where I click.
Hey there, the button solution is a bit sketchy in my opinion… But in that very same video where the button method is explained there is a guy that posted a much more elegant solution @fratgursoy8562
In UMG if you set a player controller’s input mode to UI Only when trying to show a modal widget, clicking in the empty/dead space of the viewport causes focus to shift back to the player controller. If you don’t want this behavior, the easiest workaround is to set the root CanvasPanel’s visibility in your modal widget to Visible instead of Self Hit Test Invisible. This will cause the CanvasPanel to absorb all click events, including the click event that would normally send your focus back to the player controller.