Subviewport not recieving any inputs

godot 4.3 steam

i have a very simple code that goes:

extends SubViewport

func _input(event: InputEvent) -> void:
	print(event)

and it doesnt print anything
note that the disable input fucntion in gui is turned off

I experienced this issue when I was designing a system to have multiple maps for a top-down 2D game loaded simultaneously. The fix is to have a script on the main viewport (in my case I have a SceneManager as the main scene of my project) call push_input on this SubViewport in the _unhandled_input function. https://docs.godotengine.org/en/stable/classes/class_viewport.html#class-viewport-method-push-input. Without more information about your code structure I can’t say specifically where you’d need to do this. This is just how I ended up handling it. This allowed for my GUI which was in the main viewport to still receive input and decide if it should be passed on to the game.

1 Like

the issue is im trying to get the input to go inside the line edit and im not sure if this will solve this (sorry for not mentioning it emideacly)

It should work, as far as I understand it, the parent viewport handles distributing events among its children, but doesn’t automatically hand it to child viewports, that step has to be done manually. Only the main viewport (the SceneTree’s root window itself) “accepts” input, but it can be passed to other viewports from there. Hopefully that makes sense.

can u elaborate more on how to use it then coz from what i read in the documentary u just

func _unhandeled_mouse_input(event: InputEvent):
push_input(event)

and then accept it in the viewport
but this doesnt seem to do what i want

i ve realized that it works as a whole function and it actually works thanks