From d41665eb5e38500e5867173203ed977f683bec77 Mon Sep 17 00:00:00 2001 From: Markus Sauermann <6299227+Sauermann@users.noreply.github.com> Date: Thu, 15 Jun 2023 12:20:04 +0200 Subject: [PATCH] Fix position and size of MenuButton popup Use the same logic as in OptionButton::show_popup --- scene/gui/menu_button.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp index f75b761d6e4..4e80d7a2d6d 100644 --- a/scene/gui/menu_button.cpp +++ b/scene/gui/menu_button.cpp @@ -97,15 +97,14 @@ void MenuButton::show_popup() { } emit_signal(SNAME("about_to_popup")); - Size2 size = get_size() * get_viewport()->get_canvas_transform().get_scale(); - - popup->set_size(Size2(size.width, 0)); - Point2 gp = get_screen_position(); - gp.y += size.y; + Rect2 rect = get_screen_rect(); + rect.position.y += rect.size.height; + rect.size.height = 0; + popup->set_size(rect.size); if (is_layout_rtl()) { - gp.x += size.width - popup->get_size().width; + rect.position.x += rect.size.width - popup->get_size().width; } - popup->set_position(gp); + popup->set_position(rect.position); // If not triggered by the mouse, start the popup with its first enabled item focused. if (!_was_pressed_by_mouse()) {