Hide the mouse cursor in a UMG menu when a gamepad is used

I have menu system created in UMG. It allows mouse, keyboard and gamepad inputs. The thing is, I would like the mouse cursor to disappear when a gamepad is in use. To me it seems logical to test a keypress and check if that came from a gamepad or not. If it does, hide the mouse cursor!

I am using a function override called OnKeyDown:

Now I am probably missing something or there is something I don’t understand! When navigating the menu with a gamepad the left stick and d-pad moves the focus field around to the individual buttons and the ‘face button down’ is used to “click” on a button. This override function works with all the other keys, but not the ones used to control the menu.

Is there a way to do a similar check on the left stick, d-pad and ‘face button down’ in a widget blueprint (or include them in this function)? Or is there another way to do this?

Yes, I know. My problem is how to include ALL the keys on the gamepad when I check which buttons are pressed!

The function in my screenshot is just checking unused buttons, unfortunately. :frowning:

Thanks for answering!

To Hide the mouse cursor you can use “Set Show Mouse Cursor”

Okay, so now I feel really stupid!

OnPreviewKeyDown and Unhandled did the trick:

I find the answer to something shortly after posting a question about it. I really should ask a LOT more questions!!! :slight_smile:

With Input Mode: Game and UI you can’t hide the mouse cursor by setting Show Mouse Cursor tho. I’m trying to figure out how that would work… I can’t hide the cursor when the gamepad is used.

You might want to turn game-only input back on when you detect gamepad input since you won’t be using the cursor that handles ui input anyway (I presume) I toggle to game-only input and then hide cursor when any gamepad input is detected, and toggle back to game&ui mode as soon as any non gamepad input is detected.

1 Like