Godot Version
4.6.3
Question
With reference to Display context menu in 3D when clicking on Node I want to replace my VBoxContainer with a PopUpMenu element.
I am setting the position of the PopUpMenu by using
%PopupMenu.position = offset
where offset is the Vector2 screen coordinate.
But no matter what I do, the PopUpMenu always appears in the top left corner of the screen.
Is there anything I am missing here?
PopupMenu.position , as an inherited property from the Window class, seems to have some rules attached to it.
The doc I linked mentions: “Note: This property only works if initial_position is set to WINDOW_INITIAL_POSITION_ABSOLUTE.”
Is this the case?
Well, the doc also mentions calling one of the many popup* methods, which take a Recti as parameter for positioning.
Have you tried using that?
It worked for me, I’m quite sure.
Thanks, that pointed me in the right direction!
func positionMenu(offset: Vector2):
self.show()
if offset:
var rect: Rect2i = Rect2i(offset.x, offset.y, 800, 800)
%PopupMenu.popup(rect)
jamie
June 4, 2026, 7:24am
6
That approach makes sense. Another option is to project the 3D click position into screen space and then show a regular PopupMenu at those screen coordinates. You still get the context-menu behavior, but without having to build a fully interactive 3D UI.
@jamie Isn’t that what I am doing here? I am using the PopupMenu and have no 3D UI.