Disable all input

I would like to tell the engine to completely stop sending on_input events until told otherwise.

The case being when we are transitioning between states, screens, popups, etc. some buttons will usually animate out while new ones are animating in and it would make sense to disable input until the transitions finish without having to check for state flags inside every botton callback and everywhere else that can receive input.

This becomes helpful when your gui is made out of a different, independent sections that are loaded, enabled and combined in different arrangements depending on game state and you want to preserve the input stack.

Perhaps you can create a new game object, and acquire the input focus (which is implemented as a stack), and always return true from that on_input?

2 Likes

Similar to what @Mathias_Westerdahl says

Create an input blocker module, require it in all of your scripts which use input, then on the on_input function check to see if input is blocked at the very top of the function and return true so that it skips the rest of the on_input function. Then set the input blocker module’s block state to true/false depending on if you are wanting to disable all input or not.

1 Like

Yes that would be a good enough solution, thank you. It just seemed to me like a common use-case so it would still be nice to have a simpler alternative without the additional clutter.

2 Likes

Another solution that we use is that you have a loader collection that loads all other collections anyway in proxies. If you remove inpute focus from the gameobject holding the proxies you will not get any input focus in those collections.
In my opinion this is the simplest and cleanest way

2 Likes

Yes, ofc, this is the best solution! No idea why I didn’t think of this before… Most larger games have a loader collection anyway.

1 Like

Another reason to use a module is to have tags which enable / disable input for differently tagged scripts at once. But that can still be done with the GO method and with less clutter.

Related to input I still really want a go.acquire_input_focus() and gui.acquire_input_focus() please!

1 Like