Skip to content

Commit

Permalink
Merge pull request #61686 from YeldhamDev/weird_bugs
Browse files Browse the repository at this point in the history
Fix specific bug related to submenus in `PopupMenu`
  • Loading branch information
akien-mga authored Jun 5, 2022
2 parents 4ff41cc + b4e4f88 commit ef8401e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scene/gui/popup_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ void PopupMenu::_activate_submenu(int over) {

pm->set_position(pos);
pm->set_scale(get_global_transform().get_scale());
pm->popup();

PopupMenu *pum = Object::cast_to<PopupMenu>(pm);
if (pum) {
Expand All @@ -175,6 +176,7 @@ void PopupMenu::_activate_submenu(int over) {
pum->set_current_index(0);
}

// Setting autohide areas *must* be done after `popup()` which can move the popup (to fit it into the viewport).
pr.position -= pum->get_global_position();
pum->clear_autohide_areas();
pum->add_autohide_area(Rect2(pr.position.x, pr.position.y, pr.size.x, items[over]._ofs_cache));
Expand All @@ -183,8 +185,6 @@ void PopupMenu::_activate_submenu(int over) {
pum->add_autohide_area(Rect2(pr.position.x, pr.position.y + from, pr.size.x, pr.size.y - from));
}
}

pm->popup();
}

void PopupMenu::_submenu_timeout() {
Expand Down

0 comments on commit ef8401e

Please sign in to comment.