0 votes

Hi everyone,

I front-z-indexed a popup including a panel which stops mouse input so nothing behind it can be clicked while the popup is open.

get_node(0815).z_index = 10

(Closing sets it back to 0)
Now I realize that this only works on anything lower in the tree...

I thought that z-index means tree-position, but now I wonder if z-indexing something is basically only a „visibility“-thing but does not mean changing the order inside the tree?
So how could I put my popup on top of the tree?

Godot version 3.3
in Engine by (455 points)

As Popups are Control nodes, they don't have a z-index. Are you using a Node2D instead? Because Popups automatically stop mouse input.

Indeed I built my own "popup" featuring some buttons, sprites and labels etc., and it's based on a Node2D. The structure is somewhat complex with different branches and I put that mouse-stop-Panel in place where I can still tap buttons above (I realize I could also use a ControlNode for the input-stopping...).

The popup (and its "activation-button") is just placed somewhere within the sceentree, like:

- some element
- another element
- popup
- more elements
- even more elements
- (wanted temporary position)

With the z-index I can visually place it on top of each other as soon as I press its activation-button. The problem is that "more elements" and "even more elements" still remain on top of it "access-wise", so for example buttons of those elements will still trigger when I interact with my popup...
So I need my popup not only visually but "really" to jump on top of everything, meaning (temporarily) below (above!?) "even more elements" within the sceen tree.

(You understood all this from the beginnig, I just clarified it once more for myself and maybe some other beginners... ; )

So what I'm looking for is some eqivalent for z-index but not only for visuals.

Why not just use the Popup control nodes? Or maybe you can adjust the mouse filters of control nodes?

The ControlNodes really do work as do the Panels. I also experimented with CanvasLayers, which offer some very useful qualities.

Still, in my case, there always remains a button clickable (or visible) in front of the popup, so I guess I'll have to rebuild these elements disconnecting the popups from their buttons so I can put all the buttons somewhere lower and all the popups higher in the structure. That would certainly do.

I was hoping for a z-index for more than visuals but also for tree-positon - I'd say such a thing would be very handy.

If you want to, you can suggest it on GitHub.

Actually, in the meantime I believe that what I'm looking for are things like add_child(), add_child_below_node(), move_child(), remove_child(), get_child_count(), get_index(), get_position_in_parent ( ) , raise() etc., I just didn't realised those as what they are... probably because I have a hard time implementing them into the code. It's one of those examples where the docs show me the what but not the how...
But I'm sure one (or more) of these methods will help moving nodes around.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.