Random beginner-question: z-index panel for mouse-stop in front of tree

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

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?

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

exuin | 2021-06-10 22:19

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.

pferft | 2021-06-11 08:47

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

exuin | 2021-06-11 23:19

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.

pferft | 2021-06-12 15:48

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

exuin | 2021-06-12 15:51

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.

pferft | 2021-06-13 15:30