How do I handle input both with and without focus?

FYI, I’m working with a version of the UnrealImGui plugin, if that helps you.

The issue I’m having is that I can’t manage to implement a single place for dealing with the input for showing and hiding our debug menu.

When the menu is closed, it can’t receive any input events because it is not the focus in Slate. As such, we’ve implemented something in the cheat manager for opening the menu.

When the menu is open, the menu is the focus in Slate and so the events don’t make it to the cheat manager (ImGui consumes them otherwise we would be passing inputs along to the game while the menu is open). This means that we have to handle the close in the ImGui code.

How can I unify this into a single place for handling the input?

I was able to get some help on this. What I did was implement an Input Preprocessor (see FSlateApplication::RegisterInputPreProcessor). These are executed before any other input handling and have the opportunity to intercept and (optionally) terminate input events. I just had to create a new IInputProcessor and register it and that was it.