Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubViewport rendered as ViewportTexture doesn't receive InputEvents #79827

Closed
ascripter opened this issue Jul 23, 2023 · 3 comments
Closed

SubViewport rendered as ViewportTexture doesn't receive InputEvents #79827

ascripter opened this issue Jul 23, 2023 · 3 comments

Comments

@ascripter
Copy link

Godot version

v4.1.stable.official [9704596]

System information

Godot v4.1.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce 940MX (NVIDIA; 31.0.15.1654) - Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz (8 Threads)

Issue description

When projecting a SubViewport as a texture (i.e. tested with ViewportTexture for Sprite2D and Sprite3D), and the scene inside the SubViewport contains any Control elements, they are not accessible / don't receive any InputEvents.

Explicitly forcing them to get the focus via Control.grab_focus() seems to work, but then any input is just ignored. Tried it with and without SubViewport.handle_input_locally, as well with callback-scripts that reside in nodes inside and outside the SubViewport.

Steps to reproduce

The attached project has two buttons, the "outer" is a child of the main node, while the "inner" is projected as a Sprite2D's texture. The inner button can't be pressed, no matter how I try it.

Minimal reproduction project

viewport_test.zip

@AThousandShips
Copy link
Member

AThousandShips commented Jul 23, 2023

I'm not sure this is supposed to work, they should be in a SubViewportContainer to have access to this functionality AFAIK

I think you need to pass the input forward to the viewport in this case, see here

@Sauermann
Copy link
Contributor

You can find a rationale for the current behavior in #9950 (comment)

So you have two options:

  1. Use a SubViewportContainer, which automatically sends events to its child SubViewports.
  2. Implement InputEvent-propagation based on your individual requirements from Sprite2D. (In the post above you find a link for how to do this in a 3D-application)

I would like to close this issue, since the current behavior is expected and also documented in https://docs.godotengine.org/en/latest/tutorials/inputs/inputevent.html

@Sauermann
Copy link
Contributor

If you need the functionality for 2D/3D in an automated way, you could give a thumbs-up to the proposal godotengine/godot-proposals#6524

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants