diff -r f40bd6f0f6cf lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp --- a/lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp Wed Sep 23 15:19:24 2009 +0200 +++ b/lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp Wed Sep 23 15:22:13 2009 +0200 @@ -670,9 +670,21 @@ void CGUIContextMenu::recalculateSize() const s32 w = Items[i].SubMenu->getAbsolutePosition().getWidth(); const s32 h = Items[i].SubMenu->getAbsolutePosition().getHeight(); - Items[i].SubMenu->setRelativePosition( - core::rect(width-5, Items[i].PosY, - width+w-5, Items[i].PosY+h)); + core::rect subRect(width-5, Items[i].PosY, width+w-5, Items[i].PosY+h); + + // if it would be drawn beyond the right border, then add it to the left side + gui::IGUIElement * root = Environment->getRootGUIElement(); + if ( root ) + { + core::rect rectRoot( root->getAbsolutePosition() ); + if ( getAbsolutePosition().UpperLeftCorner.X+subRect.LowerRightCorner.X > rectRoot.LowerRightCorner.X ) + { + subRect.UpperLeftCorner.X = -w; + subRect.LowerRightCorner.X = 0; + } + } + + Items[i].SubMenu->setRelativePosition(subRect); } } }