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

Control inside Viewport inside ViewportContainer ignores gui-event tree order and is in front #48401

Closed
Reneator opened this issue May 3, 2021 · 3 comments

Comments

@Reneator
Copy link

Reneator commented May 3, 2021

Godot version:
v3.3 stable

OS/device including version:
Windows 10

Issue description:

with a scene-structure like this:
image

The TextureRect is drawn in the right order (behind the button), but the TextureRect (set to mouse_filter_stop) catches all the mouse-inputs.
Therefore i cant click on the Button where the TextureRect is being displayed in the ViewportContainer:
Viewport_Cointainer_Control

In my game i have a world-map which is inside of a viewportContainer where the buttons block mouse-inputs even though they are not visible (either behind another UI-Element or even outside the viewport).
I have a complicated workaround for this in my project, but it still doesnt solve the basic problem of the button being in front.
The workaround checks if the mouse exits the viewport-container (as this control element is still properly handling the mouse-input) and switch the mouse_filter to Ignore for the buttons. But this doesnt work if the mouse is still inside of a button as it leaves the map:
Viewport_Cointainer_Control_Game

I was expecting the texture-rect to have the same gui_input order as it is drawn (texture_rect is behind the button)

Steps to reproduce:
In the project the native behaviour is replicated. Run the project and see how the textureRect inside the viewport is actually soaks up the mouse-input as if it were in front.

Minimal reproduction project:
Viewportcontainer replication project.zip

@Calinou
Copy link
Member

Calinou commented May 3, 2021

Related to #48368.

@dkaste
Copy link
Contributor

dkaste commented Jun 2, 2021

I think I figured out why this is happening, but I'm not sure if I will have time to fix it.

See the following lines in Viewport::input() (linking Godot 4's code, but the same thing applies in 3):

if (!is_input_handled()) {
    get_tree()->_call_input_pause(input_group, "_input", ev, this); //not a bug, must happen before GUI, order is _input -> gui input -> _unhandled input
}


if (!is_input_handled()) {
    _gui_input_event(ev);
}

The code in the first block leads to SubViewportContainer::_input() being called, which in turn calls the child's own Viewport::input(). The child viewport then runs_gui_input_event(), which consumes the event. When the parent viewport exits _call_input_pause(), the event as already been marked as handled, so the GUI ignores it.

@akien-mga
Copy link
Member

Duplicate of #39666

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