Open deermen001 opened 4 years ago
@deermen001 Please upload a minimal reproduction project to make this easier to troubleshoot.
Also, which Godot version and operating system are you using? (Please fill in the issue template if you plan on reporting other issues.)
@deermen001 Please upload a minimal reproduction project to make this easier to troubleshoot.
Also, which Godot version and operating system are you using? (Please fill in the issue template if you plan on reporting other issues.)
I edited my comment as per your guidelines. Please correct me if there is still something wrong.
I second the issue. Both PopupMenu and PopupPanel don't use relative to parent position.
Godot version: Godot Engine v3.2.3.stable.official OS/device including version: Windows 7
Steps to reproduce:
- Node2D
-- PopupMenu (or PopupPanel)
Minimal reproduction project: popup_issue.zip
As of 3/3/2021 this is still an issue. The PopupMenu node does not seem to inherent relative position from its parent.
Godot Version: Godot Engine v3.2.3.stable.official OS: Windows 10
I am able to work around it by making a function to set the inheritance manually in its parent:
Scene:
-Node2D
--Popup Menu
Script attached to Node2D:
extends Node
onready var popup = $PopupMenu
func _process(delta):
popup.rect_global_position = self.position
Alternatively, if you don't need to update the position every frame, you can put "popup.rect_global_position = self.position" right before you need to show the actual popup, assuming that behavior is controlled from the parent node.
This is an annoying problem. I want the popup to popup, aside: popup() for vector2 parameter should be an issue, above the button, not over it. So, I worked out a solution that is dynamic to changing game window resolutions/resizing.
extends {parent node; preferably HBoxContainer or other control derived node}
var menu_position
var vertical_offset = 0
onready var zoning_button = get_node("Zoning") # Button
onready var zoning_menu = get_node("Zoning/ZoningMenu") # PopupMenu
# I know I should use MenuButton, but this is just how I did it.
func _ready():
menu_position = zoning_button.rect_position
vertical_offset = zoning_button.rect_size.y + zoning_menu.rect_size.y
func _on_Zoning_pressed():
# If you don't plan a resizable window, then move assignment and setter code to bottom of _ready()
menu_position.y = OS.get_window_safe_area().size.y - vertical_offset
zoning_menu.set_position(menu_position)
zoning_menu.show()
Feels like a hacky workaround, but it works for Godot 3.3.2!
OS.get_window_safe_area() is a very useful function. which helped me solve many positioning problems in past projects. Probably should not be the go to function, but it is a fix to position vexing nodes like Popup and its derivatives. Layout button and container nodes are best for positioning gui.
I'm having the same issue in 3.3.3 stable on macos
This still does not seem to be solved.
I also got this bug.
This may or may not be helpful for the devs when debugging:
I only started encountering this bug once I created a Window HelpWindow
somewhere else in the scene tree. Before that, the Position of i.e. File
was relative to FileButton
.
Further, the issue goes away if I set "Embed Subwindows" to true, but that won't work for my project.
Note: This issue has been confirmed several times already. No need to confirm it further.
OS : Windows 10 Godot version : 3.2 Issue.zip
I attached popup menu as child node of a 2d node. I moved the parent node with which the popup menu node moved in the editor but on running it still shows it at previous position.
I think the popup menu relative position property is interpreted as absolute global position.