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

Fix position and size of MenuButton popup #78269

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions scene/gui/menu_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down