In my Project (multiplayer - Coop) i create the Player hud within the Player Controller. Then, if i want to Show the mouse with set Input mode ui only, that works. But, if i want to disable the mouse Cursor, the Input key from the Keyboard is disabled.
This happens only with Input mode ui only. If i use Input mode game and ui, then the key works.
The same Setup is used in the Version 4.15. In this Version the Setup worked. But now with 4.16.2 it don’t work.
The only Thing i can do is to set a button in the Widget to Close inventory mouse.
If you set it to UI only - Player Controller and others never get any Input from the Viewport.
Game and UI - is a mix that can give the Focus back to your Viewport temporarly if clicked outside of any focusable UI Elements.
Game only will Focus your Viewport. It does not prevent the UI from reciving Clicks (if mouse coursor is shown) or Key events when Focused.
Sometimes its helpful to go into Project Settings → Engine → User Interface and change the Render Focus Rule to “Always” that will highlight the Element of the UI that has Focus. Not all but many UI Elements are focusable like Buttons (is a Option in the Details)