TLDR; How would you setup Common UI in a project that should work on a PC that doesn’t have a mouse? For real.
Has anyone figured out a way to disable the mouse input and cursor entirely in a Common UI setup? I’m working on a project that is PC and Console compatible and the UI menus should be keyboard and d-pad navigable only. A mouse or controller cursor should have no business in the UI. I’ve come across a ton of posts touching on the matter pre-Common UI, but nothing seems to work or really cover what I’m trying to accomplish here.
I’ve followed the 3 hr long Epic video on Common UI and have adapted a bunch of UI BP/C++ from the Lyra example so I have a nice setup that switches contexts between PC and Console via input detection and shows platform specific action icons relative the active platform.
It seems no amount of mouse input/cursor disabling props/commands on the Player Controller or on the Activatable Widgets have any impact what so ever. The cursor and it’s movement input will just not go away, nor also do any keyboard WASD or arrow key input actually navigate menu buttons at all.
The closest I have come, which isn’t quite good enough, is un-checking “Supports Mouse and Keyboard” under the Windows Platform Input in Common UI Input Settings, along with a Default Input Type of Gamepad. It removes the mouse cursor entirely and allows keyboard input navigation, along with controller d-pad input navigation, which is great, but the context switching between PC and Console doesn’t happen any more, as evident by the Common Action Widget icons remaining Console related. Also, mouse and controller joystick input still seem to navigate button selection, despite their cursors being not visible.
I’ve been digging around the engine code trying to figure out some options. I get a sense that tinkering with UInputBehaviorSet and/or UInputRouter might be of interest but I lose the trail trying to connect them back to anything I can adjustable or override, such as the UCommonGameViewportClient or Player Controller.
Alright, I think I figured it out. A little hackier than I’d preferer but it does the job.
There are a few parts to it.
Hiding mouse cursor and blocking mouse movement input (from hovering over buttons.)
In the Widget Stack Layout (See above video and/or Lyra Project,) add a full screen Canvas with Visibility: Visible and Cursor: None.
in NativeOnFocusChanging check that FFocusEvent was caused by mouse and new focused widget type is SViewport or for editor - SPIEViewport and prevent such event by focusing back button, not ideal but good solution in my case .h