[SOLVED] Enable / disable input for entire application from GDScript

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By radubolovan
:warning: Old Version Published before Godot 3 was released.


How can I enable / disable input for entire application from GDScript?

The desired effect is that all input devices (mouse, keyboard, controllers, touches, etc) will be enabled / disabled for the entire application from GDScript.

Best regards,

[Later edit]: Using 2.1.4 official stable
[Update 2018, 25th July]: This also works in 3.0.5 official stable.

:bust_in_silhouette: Reply From: Zylann

I don’t think there is a way to do this on engine level, but it’s possible if you simply stop processing input in all your scripts.
You would also need a fullscreen invisible Control on top of everything to prevent mouse input from going through, and give it focus so key/button focus won’t access anything.

What is the use case for this?

:bust_in_silhouette: Reply From: radubolovan

Found the solution:

  1. add a Control object as the root of the scene
  2. add a script to the scene (inherited from “Control”)

To disable the input:


To enable the input:


Looks like on Windows, even if the input is disabled “Alt +F4” still works though. Everything else is “dead”.

Oh yeah… there is that, since the game has a default viewport, which is the tree root. It’s better than putting a fullscreen Control^^
You still need to stop any script from polling the Input class though.

Zylann | 2018-01-06 01:33

Couldn’t he also pause the tree? It might not work very well if he wants to run physics though.

Sojan | 2019-07-30 18:54

btw i cant use the code when I attach it to AnimationPlayer node

alanzulwas | 2021-09-21 11:44