Disabling mouse cursor requires extra click to re-enable mouse X/Y

When I enable my mouse cursor, click around with it for a bit and then disable it through anything other than a mouse click, the mouse X/Y axis inputs do not function for anything else until a mouse click is made. Also if I hold down a mouse button while disabling the cursor, it works as it should.

How can I remove the need to click to re-enable X/Y axis inputs after the cursor has been disabled?
The blueprint I’m using to disable/enable the mouse is below.

1 Like

I’m experiencing the same problem even in Standalone mode. For example::

  1. Hit “F” key to bring up Inventory, enable the mouse
  2. Successfully click on panels and whatnots
  3. Hit “F” key to close inventory, disable the mouse

However, the mouse look does not work until I hit a mouse button. I ideally I shouldn’t have to do the extra mouse click to regain control of the mouse look.

to release the mouse control
bShowMouseCursor = false;
bEnableClickEvents = false;
bEnableMouseOverEvents = false;

I’ve tried adding:
FSlateApplication::Get().SetFocusToGameViewport();

Currently, i’m tracing down the states on why the mousebutton regains control in the code, but the hunt is slow. Any suggestions? I’m currently blocking out the following code area but I could be far off still :

FReply FSceneViewport::OnMouseButtonDown( const FGeometry& InGeometry, const FPointerEvent& InMouseEvent )

Well, I was able to figure out the problem and the fix for the c++ side. Basically, the problem is with which slatewidget has focus and then to refocus back onto the clientviewport.

To release the mouse and regain “Mouse Look” for C++:

//Release the mouse events and don't draw the mouse
		bShowMouseCursor = false;
		bEnableClickEvents = false;
		bEnableMouseOverEvents = false;

// Since the viewport may not be the current focus, 
// we need to re-focus whatever the current focus is,
// in order to ensure it gets a chance to reapply any custom input settings
		auto CurrentFocus = FSlateApplication::Get().GetKeyboardFocusedWidget();
		FSlateApplication::Get().ClearKeyboardFocus(EKeyboardFocusCause::SetDirectly);
		FSlateApplication::Get().SetKeyboardFocus(CurrentFocus);

Maybe you can use this information to figure out the blueprint method equivalents. Hope it helps.

Ah alright, I’ll see if I can do anything with blueprints, if not I’ll just have to add the code in. Cheers.

I am getting an error:
" use of undefined type ‘FSlateApplication’ "

EDIT: an #include “SlateBasics.h” fixed the problem… but nevertheless this approach doesn’t work for me. Still no reanabling the mouse look.

EDIT2: Nevermind, it works now… I changed the bools after the FSlateApplication-Lines

Just saw this question while looking for the answer myself. Little late, but this is a way of how you could do it on the blueprint side:

Yep, ^ easiest way right there

There are two standard functions in the Blueprint:

1 Like

Sadly this does not actually work. Still requires a click afterward.

This does not solve the problem that it requires a click after changing showMouseCursor

I’m facing the same problem, and it does not solve my problem too.

I duduned figured it out!

Hey I figured it out here-

Hey I figured it out here -

None of these suggestions worked for me, but I found a way.

I noticed the Set Input Mode Target input didn’t have “Target: Self” like nodes usually do, but instead just “Target”, so I chucked a self ref on it and the problem was gone!, remove the self and it returns.

http://i.imgur.com/lAt4nMK.png

Ignore the “In Widget to Focus” input, that isn’t required, but I passed it through anyway. why not? :smiley:

I didn’t have any issues going back to game only input mode. but here’s the bit that does that from the widget graph.

http://i.imgur.com/savEY6H.png

Good news =)

This Problem re-appears in 4.11

Did you ever figure this out?

EDIT:
Oh hmm nvm you need to call SetInputModeGameOnly on the player controller.

This did solve my problem.