Every time I open or close the widget, I have to click on the screen to make it work.

*I’m using a translator, so the sentences may be awkward.

There is no problem when opening and closing the widget by simply pressing a key without using the mouse. When the widget is turned on, the view stops moving. And as soon as the widget is turned off, the view changes according to the movement of the mouse. It’s successful up to this point.

However, when I open the widget, the widget’s buttons and other interactive elements do not respond until I click the screen once. Even when I overlap the mouse, there is no hover response and no clicks. As a result, if I want to open the widget and press the button, I have to click the screen twice. Every time I close and open the widget.
A more serious problem occurs when I click the widget with the mouse and then close it. When I move the mouse, the character’s head does not move, but the mouse moves outside the screen like in the video. The mouse will not interact with the game until you click the screen again. It’s as if I pressed Alt+Tab to exit to another window.


I know how to use the following nodes, and I’ve tried many things such as focusing and unfocusing the widget, but nothing changes. I also differentiated the mapping context between user assets and UI assets.

image

I searched for various cases, tried using these nodes, and changed things related to ‘Mouse capture mode’ in the project settings, but the problem was not solved. Is there any other solution? Or is it a problem with my PC environment, not Unreal Engine? I’m confused because I’ve looked at other YouTube lecture videos on creating and using WIdget, but this problem doesn’t seem to occur. Please help me.

Ah, this infamous issue is still alive and well I see.

There are different solutions. What Unreal Engine version are you using and are you using CommonUI?

I am not using the Common UI plugin and my Unreal Engine version is 5.3.

I had a hard time searching because it’s hard to explain these issues in one sentence. I think this is a pretty critical issue. Has anyone solved this issue?

I’ve solved this for every version since 4.x. But it’s different every time.

You showed us all three states of Input mode. Which one are you using for the UI?

In your project settings under Engine/Input, can you show a screenshot of your settings for Viewport Properties? In most cases, this should be set to “Capture Permanently Including Initial Mouse Down”.

Also, your widget must be set to be focusable. This is why I like CommonUI because it takes care of all the focus issues and you can set a default focused sub widget. If you’re just using the regular widgets, you have to do this manually. There should be a checkbox or something somewhere.

A problem with using BP to set the Input Mode is that it changes your capture settings. So what you should do is find a setting in the projects settings that works the first time you try to bring up the UI. Once you have that, you must add nodes after setting the Input Mode to restore those settings especially the capture mode. So as weird as it sounds, you have to use “Set Viewport Mouse Capture Mode” AFTER setting the input mode to restore the capture mode to what you used to have.

Then you can work on the Game Only mode (or whatever is it you’re using when the UI isn’t up).

In 5.4, you don’t even use capture mode anymore. You just use UI input config and it’s a lot easier.

As you mentioned, I changed the initial mouse capture mode in the project settings.

And this is the input action configured in the Player Controller Blueprint. Both IA_Inventory and IA_CloseUI are bound to the Q key. IA_Inventory is contained in IMC_Default, and IA_CloseUI is contained in IMC_UI.

If you look at the bottom right, there is a node that resets the mouse capture mode.

The ‘FL_ControlForWidgetOrGame’ function is included in the Blueprint function library. This was created to simplify changing mouse settings or input modes in various Blueprints.

image

You may not be able to read it because it’s in Korean, but I clearly enabled this to enable focus on the widget.

As a result, there was some success. Originally, ‘Game and UI’ was not used. I only used ‘UI Only’ and ‘Game Only’. However, when I used ‘Game and UI’ instead of ‘UI Only’ when opening the widget, I was able to press the button with one click.
But sadly, the problem has not been completely resolved. Closing the UI no longer moves the mouse out of the viewport, but I still have to click the screen once to turn my character’s head.

You have already helped me a lot, and I am grateful for that. But if you don’t mind, could you please check to see if I missed anything?

Ok, so after you open the UI and you’ve set the input mode, try setting the capture mode to just “CapturePermanently”. After you close the UI and set the input mode, set the capture mode to “CapturePermanently_IncludingInitialMouseDown”.