Merge pull request #78269 from Sauermann/fix-menubutton-popup-position
Fix position and size of MenuButton popup
This commit is contained in:
commit
a48285db7b
1 changed files with 6 additions and 7 deletions
|
@ -97,15 +97,14 @@ void MenuButton::show_popup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
emit_signal(SNAME("about_to_popup"));
|
emit_signal(SNAME("about_to_popup"));
|
||||||
Size2 size = get_size() * get_viewport()->get_canvas_transform().get_scale();
|
Rect2 rect = get_screen_rect();
|
||||||
|
rect.position.y += rect.size.height;
|
||||||
popup->set_size(Size2(size.width, 0));
|
rect.size.height = 0;
|
||||||
Point2 gp = get_screen_position();
|
popup->set_size(rect.size);
|
||||||
gp.y += size.y;
|
|
||||||
if (is_layout_rtl()) {
|
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 not triggered by the mouse, start the popup with its first enabled item focused.
|
||||||
if (!_was_pressed_by_mouse()) {
|
if (!_was_pressed_by_mouse()) {
|
||||||
|
|
Loading…
Reference in a new issue