Keyboard loses focus when opening HUD element

When I open my inventory HUD with TAB, i can’t close it. The only way to close the HUD is to first click on the screen and then press TAB

How is the Tab key pressing implemented in the the widget’s onKeyDown? Is the widget keyboard focusable?

Here’s the whole shebang:


I see you’re using Input Mode Game and UI but it’s pretty much the same case. You grant Character Sheet focus - the PC cannot process input unless the widget loses it. Clicking on the screen does it, the PC gets focus back and the ability to process input again.


Consider implementing the Tab → Close in the widget. Or do not give the widget focus in the first place. Kind of depends on how you need the whole thing to work.

I was using a flip/flop, clearly not the way!

I followed the link and while it does work, the UI seems to stretch across the whole screen which is not intended

This has little to do with the original issue, though. Either use a canvas and place elements there or:

image