Popup submenu position enhancement

This commit is contained in:
neikeq 2015-11-22 15:53:22 +01:00
parent cf3ae61a7f
commit 9797b6374b
1 changed files with 8 additions and 1 deletions

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>();