Cant hide Mouse Cursor again

i cant hide the mouse cursor again. neither ShowMouseCursor = False, nor SetHardwareCursor = None seems to work. well, sometimes it works, but most of the time it doesnt. i can move the mouse cursor around as much as i want, but nothing happens. the old cursor is still visible. only after clicking, the cursor finally disappears. tested with PIE and standalone window.

When the widget receives focus it starts using its own settings for the cursor, overriding the controller. By default the cursor is visible when interacting with the widget. If you tick the Cursor checkbox and set it to none, your cursor will disappear even if the widget stays in focus:

220687-untitled.png

I’m 99% sure that’s how it works.

then the cursor would still be visible after clicking, because the widget still has the focus. as soon as you click, the cursor disappears. therefor, this is a bug. edit: actually it doesnt. clicking in the back, makes the widget lose its focus, which explains why the cursor gets updated. i keep forgetting about that, because i worked around that “issue”.

i noticed the overriding thing with my custom/border widget, which i also personally consider a bug. when you not specifically tick the cursor checkbox on, the mouse cursor should not pop up on its own, as long as ShowMouseCursor is set to false. it should always respect that setting.

the mouse cursor should not pop up on
its own, as long as ShowMouseCursor is
set to false. it should always respect
that setting.

I agree with that, sure. The current behaviour is counter-intuitive and makes workaround implementation fiddly. Essentially, for as long as the Cursor behaviour tick box is left to its own devices, I’d rather have the controller have full control over the pointer.

Admittedly, I did not test it. Knowing how UMG works, though and how often it takes over the controller (during drag&drop, for example), this is a half-expected, if undesired behaviour.

One of the many quirks of UMG, I guess.

Hello,

Thank you for submitting a bug report. I have reproduced this issue and believe what you are experiencing may be a bug so I logged a report for it here

You can track the report’s status as the issue is reviewed by our development staff. Please be aware that this issue may not be prioritized or fixed soon.

Is there a timeline or workaround to this issue? My use case requires that a widget be in focus to allow for controller input to route through it. However because it’s in focus (and this bug) the cursor remains on-screen.

Any suggestions would be appreciated.

You should upvote the bug in the tracker so it can get some lovin.

I’m not sure if you’re still looking for a good workaround for this bug but I may have one for you. I was having the same issue but for me it was because I was trying to hide the cursor when a Gamepad is being used and show it when the mouse is moved.

I created two copies of my cursor widget, named one hidden and the other shown, then created two events to set them after setting showmousecursor true or false. I don’t know if it will work for you but I figured I’d mention it in case it does.

1 Like

Tried this workaround. In one app it works, in another one it doesn’t. ;(

Dealing with this again as well. In last app we ended up doing the UI button code from scratch due to UMG problems with focus getting stuck and randomly showing the hardware cursor.

Not an option this time. Would be nice if this stuff worked. ;(

I got tired of waiting on this (don’t think we’re ever going to get a fix from Epic), so I’ve made a couple of engine changes. This worked for us but your mileage may vary. Obviously these are CODE changes, I don’t have anything useful to fix this from blueprints.

The first issue is that bShowMouseCursor on APlayerController doesn’t work. It looks like the cause of this lives in UGameViewportClient::GetCursor. What you need to do is disable/remove the first IF block in this method. This is what you should be left with:

EMouseCursor::Type UGameViewportClient::GetCursor(FViewport* InViewport, int32 X, int32 Y)
{
	if (GameInstance && GameInstance->GetFirstLocalPlayerController())
	{
		return GameInstance->GetFirstLocalPlayerController()->GetMouseCursor();
	}

	return FViewportClient::GetCursor(InViewport, X, Y);
}

Unfortunately, this by itself doesn’t do anything, because this code only runs when you move the mouse. If you’re like me and are trying to disable the mouse while a gamepad is active, you want this to reevaluate immediately. Fortunately, you can do that with a single call. I would do this whenever you modify bShowMouseCursor.

PlayerController->bShowMouseCursor = false;
FSlateApplication::Get().OnCursorSet();

The mouse should now respect the bShowMouseCursor flag and hide appropriately. However, we’re still not done, because if the cursor is above the window, it can still trigger mouse events despite being hidden. (Gamepad input changing menus would be a good cause of this.)

To fix this, you’ll want to find the method FSlateApplication::SynthesizeMouseMove. At the top of this method, add this block of code.

if (GetSoftwareCursorVis() == EVisibility::Hidden)
{
	return;
}

That should be it! The mouse should now hide and no longer trigger any events while the bShowMouseCursor is false. Hopefully this helps someone.

1 Like

Thanks a lot for this!

You can actually override EMouseCursor::Type UGameViewportClient::GetCursor in your own ViewportClient class.
We had one already cause of some Splitscreen stuff.
Not sure about the FSlateApplication::SynthesizeMouseMove stuff yet, but I doubt it will be a problem for us. Generally just want to hide the â– â– â– â–  cursor when navigating UI with a Gamepad.

Is this problem solved or not I have the same problem . I did the logic to Hide Cursor when user try using the game pad and when user try using mouse it shows Cursor but when I use the blueprint it doesn’t hid Cursor again at first its OK but when I try for second time its not hide the Cursor what should I do ? write the code in c++ as blueprint or I’m doing something wrong ? 4.21

I posted a fix below but it involves changing engine code. There’s no fix from Epic as far as I’m aware.

In my case cursor was staying visible after clicking a button and leaving the UI area where it should disappear, fixed with SetFocusTogameViewport node

1 Like

I cannot get this to work in 4.24 :frowning:

if you check the cursor box and then set it to none, mouse cursor wont show up when on that element. So, i just put an image to cover my whole screen within the mainHUD and then set the opacity to 0, so that the image does not show up during the play. I no longer see the cursor.

This bug still exists in 4.25.4… :’(

How did you work around this bug?

Could you kindly show a Blueprint script of this?