Z ordering of popup menu

Godot Version

4.2.1

Question

Hi,

I’m using a Node2D (with a child Sprite2D) as a cursor in a level editor (mouse is hidden). When I open an OptionButton’s popup menu, said menu overlaps the cursor regardless of Z-order.
Example:
problem
The cursor is that white cross.

Is there any way to fix this while still using a Node2D object as a cursor?

Thanks for the help.

put the cross on a canvaslayer

I’ve just tried it: made the cursor (the cross) a child of a canvaslayer set to layer 10 for good measure. Did not work. Same behaviour occurs, where my custom cursor overlaps the menu button but not the popup.

Popup menus seem to trump everything but the operating system cursor. Is this the case for anyone else?

Can I see your node tree

1 Like

Sure. Let me know if you need to see more.

Also, that main parent, canvas group, is visibility layer 1 if that helps.

I’m worried that the popup menu is essentially a Windows drop-menu, meaning it supersedes everything in the application.

I’ve also checked the docs for it. It’s an object called PopupMenu that’s tied to OptionButton.
PopupMenu — Godot Engine (stable) documentation in English.

No properties/methods regarding ordering.

yeah that popup menu runs through everything can you just change the cursor to the cross

1 Like

Lol I was hoping to avoid that because I’m lazy, but that will have to be the solution. Thanks for the time and help.

1 Like

As per the CanvasLayer documentation, embedded windows - of which Popup (and PopupMenu) is a child class - are placed on Z-Index 1024. Placing another CanvasItem on layer 1025 or higher should render it above the Popup; however I haven’t had the chance to test this myself. A separate CanvasLayer shouldn’t be necessary.

Hope this helps.

Regards,

2 Likes

Aha! Scholar, you’ve done it.

Z-ordering even up to 4,096 didn’t do it. It does seem have to be via the canvas ordering index rather than Z-index., which as far as I can tell can only be changed with the use of a canvasLayer(?). I didn’t see a way to change it for a lone canvas item, but it would be nice if there was one.

In Godot’s inspector, though, you can only set the canvas layer to n = 128 max. However, it can be set higher than that with a setter in code:

canvasLayer.set_layer(1025)

Which worked!
noproblem

Thank you. You two guys helped me out a ton.

2 Likes