diff -r d57711287d84 lib/irrlicht/include/IGUIContextMenu.h --- a/lib/irrlicht/include/IGUIContextMenu.h Tue Sep 02 14:36:21 2008 +0200 +++ b/lib/irrlicht/include/IGUIContextMenu.h Tue Sep 02 14:40:57 2008 +0200 @@ -122,6 +122,12 @@ \param id: Command id of menu item, a simple id you may set to whatever you want. */ virtual void setItemCommandId(u32 idx, s32 id) = 0; + + //! Make sure to show it at a good place around the given coordinates. + //! A comfort function which can for example be used after right-clicks with the mouse coordinates. + /** \param x: x in absolute screen coordinates + \param y: y in absolute screen coordinates */ + virtual void popupAt(irr::s32 x, irr::s32 y) = 0; //! Get a pointer to the submenu of an item. /** 0 is returned if there is no submenu diff -r d57711287d84 lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp --- a/lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp Tue Sep 02 14:36:21 2008 +0200 +++ b/lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp Tue Sep 02 14:40:57 2008 +0200 @@ -259,6 +259,21 @@ Items.clear(); recalculateSize(); +} + + +//! Make sure to show it at a good place around the given coordinates. +//! A comfort function which can for example be used after right-clicks with the mouse coordinates. +void CGUIContextMenu::popupAt(irr::s32 x_, irr::s32 y_) +{ + core::position2d p(x_, y_); + move( p - getAbsolutePosition().UpperLeftCorner ); + setVisible(true); + bringToTop(); + Environment->setFocus(this); + IGUIElement * root = Environment->getRootGUIElement(); + if ( root ) + moveInside( root->getAbsolutePosition(), EGUIA_UPPERLEFT); } diff -r d57711287d84 lib/irrlicht/source/Irrlicht/CGUIContextMenu.h --- a/lib/irrlicht/source/Irrlicht/CGUIContextMenu.h Tue Sep 02 14:36:21 2008 +0200 +++ b/lib/irrlicht/source/Irrlicht/CGUIContextMenu.h Tue Sep 02 14:40:57 2008 +0200 @@ -90,6 +90,12 @@ //! Returns the selected item in the menu virtual s32 getSelectedItem() const; + //! Make sure to show it at a good place around the given coordinates. + //! A comfort function which can for example be used after right-clicks with the mouse coordinates. + /** \param x: x in absolute screen coordinates + \param y: y in absolute screen coordinates */ + virtual void popupAt(irr::s32 x, irr::s32 y); + //! Returns a pointer to the submenu of an item. //! \return Pointer to the submenu of an item. virtual IGUIContextMenu* getSubMenu(u32 idx) const;