diff -r 9e599ea53284 lib/irrlicht/include/IGUIContextMenu.h --- a/lib/irrlicht/include/IGUIContextMenu.h Wed Jun 03 21:35:35 2009 +0200 +++ b/lib/irrlicht/include/IGUIContextMenu.h Wed Jun 03 21:39:10 2009 +0200 @@ -128,6 +128,9 @@ //! does the element change the checked status on clicking virtual bool getItemAutoChecking(u32 idx) const = 0; + + //! When an eventparent is set it receives events instead of the usual parent element + virtual void setEventParent(IGUIElement *parent) = 0; }; } // end namespace gui diff -r 9e599ea53284 lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp --- a/lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp Wed Jun 03 21:35:35 2009 +0200 +++ b/lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp Wed Jun 03 21:39:10 2009 +0200 @@ -280,7 +280,7 @@ if (event.GUIEvent.Caller == this && !isMyChild(event.GUIEvent.Element) && AllowFocus) { // set event parent of submenus - setEventParent(Parent); + setEventParent(EventParent ? EventParent : Parent); if ( CloseHandling & ECMC_HIDE ) { @@ -394,11 +394,10 @@ event.GUIEvent.Caller = this; event.GUIEvent.Element = 0; event.GUIEvent.EventType = EGET_MENU_ITEM_SELECTED; - if (Parent) + if (EventParent) + EventParent->OnEvent(event); + else if (Parent) Parent->OnEvent(event); - else - if (EventParent) - EventParent->OnEvent(event); return 1; } diff -r 9e599ea53284 lib/irrlicht/source/Irrlicht/CGUIContextMenu.h --- a/lib/irrlicht/source/Irrlicht/CGUIContextMenu.h Wed Jun 03 21:35:35 2009 +0200 +++ b/lib/irrlicht/source/Irrlicht/CGUIContextMenu.h Wed Jun 03 21:39:10 2009 +0200 @@ -108,6 +108,9 @@ //! Adds a sub menu from an element that already exists. virtual void setSubMenu(u32 index, CGUIContextMenu* menu); + //! When an eventparent is set it receives events instead of the usual parent element + virtual void setEventParent(IGUIElement *parent); + //! Writes attributes of the element. virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; @@ -150,8 +153,6 @@ //! Gets drawing rect of Item virtual core::rect getRect(const SItem& i, const core::rect& absolute) const; - void setEventParent(IGUIElement *parent); - core::array Items; core::position2d Pos; IGUIElement* EventParent;