How to handle input not handled by _input_event?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mburkard

I have a number of static bodies handling mouse button input using _input_event.
I have a singleton with a function I want to call on mouse button pressed but only after I’m certain that the input was not handled by anything including my collision objects.

I’ve been using somewhat hacky workarounds but I’m hoping for a proper way of handling unhandled inputs.

The built in _unhandled_input doesn’t suffice for my unhandled input since it is not the last priority input handling virtual method (why?).

Is there a way to handle input not handled by _input_event?

:bust_in_silhouette: Reply From: imjp94

According to the InputEvent documentation:
“5. Finally, if the event(CollisionObject._input_event()) was unhandled, it will be passed to the next Viewport in the tree, otherwise it will be ignored.”

So, adding another Viewport to the scene tree, then assign a script to it and capture the input with _unhandled_input(or any other input functions) should be able to handle input not handled by main viewport’s _input_event

Is that really the only way? Seems like a very clumsy method thats adds a lot of complexity.

MrSmee | 2022-02-06 18:56