Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Popup menu node not taking relative position #38171

Open
deermen001 opened this issue Apr 24, 2020 · 8 comments · May be fixed by #95001
Open

Popup menu node not taking relative position #38171

deermen001 opened this issue Apr 24, 2020 · 8 comments · May be fixed by #95001

Comments

@deermen001
Copy link

deermen001 commented Apr 24, 2020


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.

@Calinou

This comment has been minimized.

@deermen001

This comment has been minimized.

@alexontheweb
Copy link

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:

  1. Create a scene:
- Node2D 
-- PopupMenu (or PopupPanel)
  1. Move Node2D away from default top left corner. Editor shows child popup node moves along with parent as expected.
  2. Run project: Popup node would appear at window's top left corner instead of near parent node.

Minimal reproduction project: popup_issue.zip

@abardess
Copy link

abardess commented Mar 3, 2021

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.

@JonathanGrant92
Copy link

JonathanGrant92 commented Aug 22, 2021

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.

roushk added a commit to roushk/Godot-2D-RogueLike that referenced this issue Sep 9, 2021
… fix for godot popup pos issue

issue: godotengine/godot#38171

Fix is simple script to have the popup follow the actual button, it flickers so its not perfect but it works.
@Alec-15
Copy link

Alec-15 commented Sep 27, 2021

I'm having the same issue in 3.3.3 stable on macos

@BirkTorpmannHagen
Copy link

This still does not seem to be solved.

@kongehund
Copy link

kongehund commented May 15, 2024

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.

image

@rakete rakete linked a pull request Aug 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants