I added a new scene. Added popup menu. Added a few dummy items to the menu. I hooked the ‘id pressed’ to my c# script. But it never triggers. Same with index signal. All signals work fine except the popup menu specific ones. My question is how to use the popup menu? And it’s there proper documentation how to use it somewhere? Thanks on advance.
Thanks for the answer. I can see a couple of differences between our implementations. First of all you used a button to show the popup menu and I want to use right mouse click. Is that a regular button and do you use show() or popup()? Second, you use gdscript and I use C#. I suppose we can assume gdscript and C# implementations should work identically so that should not be an issue.
If nobody has any idea based on what I wrote then it’s most likely that my description wasn’t good enough. I can add more details and code later today after I get home. My implementation was roughly like this.
Scene:
Node2D
└── PopupMenu
Setup:
menu is set to visible from its properties
added four random text only items to the menu
hooked the event to a script (the script is held by the parent node)
The weird thing is that I don’t see the items react to when hovering over the menu. So the code is probably ok. There must be something preventing events reaching the popup menu specific stuff. Because as I said the mouse enter event works fine with the menu.
Okay, I’ve been looking around and this may be a bug. For some reason when the PopupMenu starts visible the flag Windows.FLAG_NO_FOCUS is set to true so it won’t focus.
If the PopupMenu starts hidden and you try to show() or set visible to true in _ready() the PopupMenu won’t be shown. If you wait a frame with await get_tree().process_frame the PopupMenu will show and works fine.
If the PopupMenu starts visible and you call show() or set visible to true then the PopupMenu will work without needing to wait a frame. You can also set Window.unfocusable to false and the PopupMenu will work fine (this property just changes the FLAG_NO_FOCUS flag).