diff -r 761a618eee3a lib/irrlicht/source/Irrlicht/CGUIModalScreen.cpp --- a/lib/irrlicht/source/Irrlicht/CGUIModalScreen.cpp Mon Sep 01 17:53:51 2008 +0200 +++ b/lib/irrlicht/source/Irrlicht/CGUIModalScreen.cpp Mon Sep 01 22:10:53 2008 +0200 @@ -24,7 +24,7 @@ setDebugName("CGUIModalScreen"); #endif setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - + // this element is a tab group setTabGroup(true); } @@ -32,7 +32,10 @@ //! called if an event happened. bool CGUIModalScreen::OnEvent(const SEvent& event) -{ +{ + if (!IsEnabled || !isVisible() ) + return IGUIElement::OnEvent(event); + switch(event.EventType) { case EET_GUI_EVENT: @@ -40,12 +43,24 @@ { case EGET_ELEMENT_FOCUSED: // only children are allowed the focus - if (event.GUIEvent.Caller != this && !isMyChild(event.GUIEvent.Caller)) + if ( event.GUIEvent.Caller != this + && !isMyChild(event.GUIEvent.Caller) + && (!event.GUIEvent.Element + || ( event.GUIEvent.Element->getType() != EGUIET_MODAL_SCREEN + && event.GUIEvent.Element->getType() != EGUIET_MESSAGE_BOX ) + ) + ) Environment->setFocus(this); return false; case EGET_ELEMENT_FOCUS_LOST: // only children are allowed the focus - if (!(isMyChild(event.GUIEvent.Element) || event.GUIEvent.Element == this)) + if ( (!isMyChild(event.GUIEvent.Element) + && (!event.GUIEvent.Element + || ( event.GUIEvent.Element->getType() != EGUIET_MODAL_SCREEN + && event.GUIEvent.Element->getType() != EGUIET_MESSAGE_BOX ) + ) + ) + || event.GUIEvent.Element == this) { MouseDownTime = os::Timer::getTime(); return true; @@ -69,7 +84,7 @@ default: break; } - + IGUIElement::OnEvent(event); return true; // absorb everything else @@ -78,7 +93,10 @@ //! draws the element and its children void CGUIModalScreen::draw() -{ +{ + if ( !isVisible() ) + return; + IGUISkin *skin = Environment->getSkin(); if (!skin) @@ -147,13 +165,13 @@ //! Writes attributes of the element. void CGUIModalScreen::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const { - // these don't get serialized, their status is added to their children. + IGUIElement::serializeAttributes(out,options); } //! Reads attributes of the element void CGUIModalScreen::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) { - // these don't get deserialized. children create them if required + IGUIElement::deserializeAttributes(in, options); } diff -r 761a618eee3a lib/irrlicht/source/Irrlicht/CGUIModalScreen.h --- a/lib/irrlicht/source/Irrlicht/CGUIModalScreen.h Mon Sep 01 17:53:51 2008 +0200 +++ b/lib/irrlicht/source/Irrlicht/CGUIModalScreen.h Mon Sep 01 22:10:53 2008 +0200 @@ -30,7 +30,34 @@ //! Adds a child virtual void addChild(IGUIElement* child); - + + //! Modalscreen is not a typical element, but rather acts like a state for it's children + //! isVisible is overridden to simulate a useful behaviour, but the same could probably be done + //! also be done by changing OnEvent and Draw correspondingly. + virtual bool isVisible() const + { + // any parent invisible? + IGUIElement * parentElement = getParent(); + while ( parentElement ) + { + if ( !parentElement->isVisible() ) + return false; + parentElement = parentElement->getParent(); + } + + // any child visible? + bool visible = false; + core::list::ConstIterator it = Children.begin(); + for (; it != Children.end(); ++it) + { + if ( (*it)->isVisible() ) + { + visible = true; + break; + } + } + return visible; + } //! draws the element and its children virtual void draw();