Merge pull request #2870 from neikeq/submenu_pos_fix

Popup submenu position enhancement
This commit is contained in:
Rémi Verschelde 2015-11-23 11:53:30 +01:00
commit 2fbc1445a5

View file

@ -170,7 +170,14 @@ void PopupMenu::_activate_submenu(int over) {
Point2 p = get_global_pos();
Rect2 pr(p,get_size());
Ref<StyleBox> style = get_stylebox("panel");
pm->set_pos(p+Point2(get_size().width,items[over]._ofs_cache-style->get_offset().y));
Point2 pos = p+Point2(get_size().width,items[over]._ofs_cache-style->get_offset().y);
Size2 size = pm->get_size();
// fix pos
if (pos.x+size.width > get_viewport_rect().size.width)
pos.x=p.x-size.width;
pm->set_pos(pos);
pm->popup();
PopupMenu *pum = pm->cast_to<PopupMenu>();