From 9797b6374bff3845130e31029eeaa544ca546653 Mon Sep 17 00:00:00 2001 From: neikeq Date: Sun, 22 Nov 2015 15:53:22 +0100 Subject: Popup submenu position enhancement --- scene/gui/popup_menu.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 99663fb2e2..20f28ecf10 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -170,7 +170,14 @@ void PopupMenu::_activate_submenu(int over) { Point2 p = get_global_pos(); Rect2 pr(p,get_size()); Ref 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(); -- cgit v1.2.3