diff -r e2b9cc8083db lib/irrlicht/include/IGUIContextMenu.h --- a/lib/irrlicht/include/IGUIContextMenu.h Tue Sep 02 13:45:46 2008 +0200 +++ b/lib/irrlicht/include/IGUIContextMenu.h Tue Sep 02 14:10:53 2008 +0200 @@ -12,6 +12,22 @@ namespace gui { + //! Close behaviour. + //! Default is ECMC_REMOVE + enum ECONTEXT_MENU_CLOSE + { + //! do nothing - menu stays open + ECMC_IGNORE = 0, + + //! remove the gui element + ECMC_REMOVE = 1, + + //! call setVisible(false) + ECMC_HIDE = 2, + + // note to implementors - this is planned as bitset, so continue with 4 if you need to add further flags. + }; + //! GUI Context menu interface. class IGUIContextMenu : public IGUIElement { @@ -20,6 +36,12 @@ //! constructor IGUIContextMenu(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) : IGUIElement(EGUIET_CONTEXT_MENU, environment, parent, id, rectangle) {} + + //! set behaviour when menus are closed + virtual void setCloseHandling(ECONTEXT_MENU_CLOSE onClose) = 0; + + //! get current behaviour when the menue will be closed + virtual ECONTEXT_MENU_CLOSE getCloseHandling() const = 0; //! Get amount of menu items virtual u32 getItemCount() const = 0; diff -r e2b9cc8083db lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp --- a/lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp Tue Sep 02 13:45:46 2008 +0200 +++ b/lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp Tue Sep 02 14:10:53 2008 +0200 @@ -25,6 +25,7 @@ core::rect rectangle, bool getFocus, bool allowFocus) : IGUIContextMenu(environment, parent, id, rectangle), HighLighted(-1), ChangeTime(0), EventParent(0), AllowFocus(allowFocus), LastFont(0) + , CloseHandling(ECMC_REMOVE) { #ifdef _DEBUG setDebugName("CGUIContextMenu"); @@ -49,6 +50,19 @@ if (LastFont) LastFont->drop(); +} + + +//! set behaviour when menus are closed +void CGUIContextMenu::setCloseHandling(ECONTEXT_MENU_CLOSE onClose) +{ + CloseHandling = onClose; +} + +//! get current behaviour when the menue will be closed +ECONTEXT_MENU_CLOSE CGUIContextMenu::getCloseHandling() const +{ + return CloseHandling; } @@ -251,7 +265,16 @@ { // set event parent of submenus setEventParent(Parent); - remove(); + + if ( CloseHandling & ECMC_HIDE ) + { + setVisible(false); + } + if ( CloseHandling & ECMC_REMOVE ) + { + remove(); + } + return false; } break; @@ -664,6 +687,8 @@ out->addInt("ParentItem", i); } + out->addInt("CloseHandling", (s32)CloseHandling); + // write out the item list out->addInt("ItemCount", Items.size()); @@ -700,6 +725,8 @@ if (Parent && ( Parent->getType() == EGUIET_CONTEXT_MENU || Parent->getType() == EGUIET_MENU ) ) ((CGUIContextMenu*)Parent)->setSubMenu(in->getAttributeAsInt("ParentItem"),this); + + CloseHandling = (ECONTEXT_MENU_CLOSE)in->getAttributeAsInt("CloseHandling"); removeAllItems(); diff -r e2b9cc8083db lib/irrlicht/source/Irrlicht/CGUIContextMenu.h --- a/lib/irrlicht/source/Irrlicht/CGUIContextMenu.h Tue Sep 02 13:45:46 2008 +0200 +++ b/lib/irrlicht/source/Irrlicht/CGUIContextMenu.h Tue Sep 02 14:10:53 2008 +0200 @@ -30,6 +30,12 @@ //! destructor virtual ~CGUIContextMenu(); + + //! set behaviour when menus are closed + virtual void setCloseHandling(ECONTEXT_MENU_CLOSE onClose); + + //! get current behaviour when the menue will be closed + virtual ECONTEXT_MENU_CLOSE getCloseHandling() const; //! Returns amount of menu items virtual u32 getItemCount() const; @@ -146,6 +152,7 @@ IGUIElement* EventParent; bool AllowFocus; IGUIFont *LastFont; + ECONTEXT_MENU_CLOSE CloseHandling; };