Download

UMG - How to get rid from the mouse cursor when giving focus?

Hi.

My PlayerController class has the flag bShowMouseCursor = false;
My game starts with the mouse hidden, an UMG mouse cursor takes place.
When adding another child widget to my Cursor screen layout it doesn’t gets focus.
On using the node “SET INPUT MODE GAME AND UI” the child widget starts to answer BUT the mouse visibitlity is restored.
Calling showmouse to false doesn’t hides it anymore.

Any tip about how I can avoid this?

Thanks

Until setting DefaultMouseCursor to None it appears… Well, I think it’s a bug.

There was a thread the fiver ago aboot show/hide mouse cursor being a bit sassy in 4.6, have you tried with 4.7 preview 2?

I’m waiting for the first stable to upgrade, my project is working fine with 4.6.1 and unless 4.7 brings DLC there is not project specifics that do requires upgrade.

I’ve reported on answerhub, but I think it will take longer to solve and I would like to start making a video from my UI today, so I’m messing with the source. :smiley:

My game opens with a menu and I need the mouse to show up, but I have no pointer until I hit shift-F1.

I think I bypassed the wilful cursor… LOL

A suggestion to 4.7

4.19, still not fixed

@**Regime X: **Not fixed because it’s not a bug. Widgets have their own cursor control and you get to choose whether to show the cursor or not.

Not a bug?

Well, I have my player controller with
bShowMouseCursor = false;
bEnableClickEvents = false;
bEnableMouseOverEvents = false;

In the UMG game menu I have literally every single widget with “Cursor = None”
When the level starts, it shows this game menu and sets input mode to “UI only” and set user and keyboard focus to the first button in the menu.
But the cusror is visible. Is that ok?
If I click somewhere in game viewport the mouse cursor disappears, but the button lose its focus so player won’t be able to navigate with keyboard/gamepad.
Additionally, even if the cursor is hidden I can still move the mouse around and the buttons will react to mouse hover event. Really?
And finally, I can click the button with invisible cursor so this button will recover the focus. But then if I move mouse out of the button bounds the cursor will become visible again.

Yup, the controller is showing the cursor but the button is set to None:

https://i.gyazo.com/43169b257ad32d8e…b61c83a3ac.mp4

It’s invisible, not non-interactive. If you do not want to interact with widget elements with the mouse cursor, set the elements’ visibility to Hit Test Invisible.

You can override what happens when the cursor leaves / enters widget. You can even override onFocusLost, to force focus back in some weird alt-tab circumstances.

Problem with this is, keyboard and controller navigation won’t be able to interact as well. I’d like to build a menu, which doesn’t react to mouse input. The only workaround I got so far is a giant button in front of everything that sets the focus to a button if clicked, but that is not only dumb, but also impracticable as it would be needed in every menu.

So my question is: Is there a convenient way to setup a menu (with UMG), which can be navigated and used only with the controller and keyboard and the mouse is completely disabled/ignored? (without adjusting mouse button down in the engine or any other engine-side changes).

4.24 and still not fixed.

My game is keyboard or gamepad only, I never, ever want to see a bloody mouse cursor!

EDIT: Jesus, if this is true then it’s so stupid…

https://answers.unrealengine.com/que…7143/view.html

Nope… didn’t work either… even if I put it in bloody tick… HOW DO I GET RID OF IT???

This does the trick for me, it’s the last answer in the answerhub post you actually linked…

And in the Menu widget

Then I can get OnKeyPress events to fire in the widget, mouse never moves anywhere.

It seems you have the MenuOptions as an array of widgets, why not make it a single widget with subwidgets, then if you Construct it with KeyboardFocus, you can override OnFocusReceived and do whatever you want with the individual widgets.

Or, alternatively, if you want the buttons separated, bind a “Listen For Input Action” node to a custom event in each one. That node listens for the input action happening in the viewport.

I know this has been a while but 4.24 still has this issue so just in case anyone sees this, I have found a solution in blueprint.

The long and short of it is your mouse cursor visibility Gets tracked in 2 locations.

REQUIREMENTS:
-Custom Game Instance
-Custom Mouse Cursor Widget

Step 1- Create a game instance and give it a Boolean Variable to track Visibility of the mouse cursor. For me I just wanted to hide if i was using gamepad so thats what I called it.


Step 2- Create whatever script you need to Show/Hide, mouse cursor. For me this is a player controller, and i use another function to detect gamepad input. the game pad input is not necessary but I will include it. Step 3- whenever you call a function to show, or hide the mouse cursor, forward the result to the game instance. the reason we use a came instance is that it can be called from anywhere.

Step 4- Create a custom mouse cursor widget. all you need is an image.

Step 5- bind its visibility to the game instance Boolean variable you made.


Step 6- now set your new cursor in the project settings as your default cursor

You should be good to go. Now the visibility of the mouse cursor is changed depending on a global variable that can be called from anywhere, and still maintains the functionality of the show/hide mouse cursor nodes. if you have any questions feel free to ask but it might take me a minute to get back to you.

That’s the best way I have saw!:slight_smile:

Thanks @Nightlocke that helped a lot! Have been looking for a solution for ages.
But I still have 2 problems.

1. Problem: Mouse is invisible but can still activate buttons
It’s the same problem @ilya.83 had and @Everynone is describing, but this solution doesn’t help me because I still want to focus the buttons with the Gamepad.
I have a workaround for this, but I’m not very happy with it.
As long as I use the gamepad I set the Mouse position to X:1 and Y:1. And if the mouse is used again, I set the position to previous position.

(
My Workaround:
If Any Key triggers because of a gamepad input, I save the mouse position X & Y and set mouse position to X1,Y1.
In my WP_Custom_Mouse_Cursor I set the position to X1, Y1 every tick as long as gamepad state is true.
If Any Key triggers because of Mouse/Keyboard Input, I set the Mouse position to the saved variables.
)

Is there a solution that simply deactivate the mouse? (“Enable Click Events” and “Enable Mouse Over Events” doesn’t work)

2. Problem: Arrows/D-Pad doesn’t work with “Any Key”, because I use the ue4 UMG Widgets
As long as I have focus on my menu buttons and navigate through my UMG, the “Any Key” node doesn’t count the inputs from Arrows/D-Pad (everything else is tracked).
I check (and uncheck) the “Consume Input” from the Any Key node but that doesn’t change anything. The tooltip for Consume Input is “prevents actors with lower priority from handling this input” so this sounds like I need this setting on my buttons in the UMG or somehow define the priority from Any Key to the highest.

I don’t have a workaround or solution for that problem, can anyone help?

This is a clever solution. (Your workaround for problem #1, setting the mouse position to X:1, Y:1).

For you problem number 2, I actually implemented this solution:

Essentially, you track the button focus states with a gated toggle. You then track the “last focused button”. I even managed to get melonheadgames solution to work in a dynamically populated button array inside a scroll box.

This is my first post I’ve made since reading these forums and dabbling in Unreal over the last couple years, as I think this problem is important and fundamental (people who want a straightforward solution to using Keyboard and Gamepad interchangeably with UMG).

I initially watched Ryan Laley’s gamepad UI tutorial, but then I wanted my core menus (before the game starts) to be interchangeable as well (I even toggle icons), and I wanted to just push F1 on keyboard, or special right to toggle back and forth. With melonheadgames solution, combined with Nightlocke’s cursor hiding illusion, and your cursor positioning hack, I can at least make it appear the switching is working without the moust moving and changing the button focus.

Anyway, clear as mud I’m sure but thought I’d post as I’ve been hunting this down all day.

I did this (Nightlocke’s fix), and it works (mouse cursor goes away). I combined it with this solution:

Dargaran, above, has a workaround if you care that although the cursor is hidden, the mouse can still click things (and in the case of the melonheadgames solution, it can also change focus).
Thanks a bunch, was hunting for something that would work all day. Also nice to confirm, while this may not be a “bug” per Epic/Unreal, it’s certainly a pain to work around.