Add gui event EGET_ELEMENT_REMOVED. Remove active focus now from elements which got removed from the gui graph.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5559 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
bb74f9034a
commit
e2ca877234
|
@ -1,6 +1,7 @@
|
|||
--------------------------
|
||||
Changes in 1.9 (not yet released)
|
||||
|
||||
- Add gui event EGET_ELEMENT_REMOVED. Remove active focus now from elements which got removed from the gui graph.
|
||||
- Fix: IGUIContextMenu now raises sub-menu when they would otherwise be displayed below bottom-border of root gui element.
|
||||
- Prevent initializing/quitting SDL several times when using more than one Irrlicht device.
|
||||
- Reduce log-messages for "loaded texture" and "loaded mesh" from ELL_INFORMATION to ELL_DEBUG.
|
||||
- Add IGUIButton::setOverrideColor to allow overriding text-color (same function as statictexts and editboxes have).
|
||||
|
|
|
@ -252,6 +252,11 @@ namespace irr
|
|||
//! may be removed by Irrlicht 1.9
|
||||
EGET_TREEVIEW_NODE_COLLAPS = EGET_TREEVIEW_NODE_COLLAPSE,
|
||||
|
||||
//! Information that an element got removed from the gui-graph.
|
||||
/** NOTE: This event is not passed on to all element parents, but only the
|
||||
gui environment (and user receiver). */
|
||||
EGET_ELEMENT_REMOVED,
|
||||
|
||||
//! No real event. Just for convenience to get number of events
|
||||
EGET_COUNT
|
||||
};
|
||||
|
|
|
@ -13,14 +13,12 @@
|
|||
#include "EGUIElementTypes.h"
|
||||
#include "EGUIAlignment.h"
|
||||
#include "IAttributes.h"
|
||||
#include "IGUIEnvironment.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace gui
|
||||
{
|
||||
|
||||
class IGUIEnvironment;
|
||||
|
||||
//! Base class of all GUI elements.
|
||||
class IGUIElement : public virtual io::IAttributeExchangingObject, public IEventReceiver
|
||||
{
|
||||
|
@ -56,6 +54,7 @@ public:
|
|||
core::list<IGUIElement*>::Iterator it = Children.begin();
|
||||
for (; it != Children.end(); ++it)
|
||||
{
|
||||
(*it)->sendRemoveEvent();
|
||||
(*it)->Parent = 0;
|
||||
(*it)->drop();
|
||||
}
|
||||
|
@ -68,7 +67,6 @@ public:
|
|||
return Parent;
|
||||
}
|
||||
|
||||
|
||||
//! Returns the relative rectangle of this element.
|
||||
core::rect<s32> getRelativePosition() const
|
||||
{
|
||||
|
@ -292,6 +290,7 @@ public:
|
|||
for (; it != Children.end(); ++it)
|
||||
if ((*it) == child)
|
||||
{
|
||||
(*it)->sendRemoveEvent();
|
||||
(*it)->Parent = 0;
|
||||
(*it)->drop();
|
||||
Children.erase(it);
|
||||
|
@ -966,6 +965,21 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
// Inform gui-environment that an element got removed from the gui-graph
|
||||
void sendRemoveEvent()
|
||||
{
|
||||
if ( Environment )
|
||||
{
|
||||
SEvent removeEvent;
|
||||
removeEvent.EventType = EET_GUI_EVENT;
|
||||
removeEvent.GUIEvent.Caller = this;
|
||||
removeEvent.GUIEvent.Element = 0;
|
||||
removeEvent.GUIEvent.EventType = EGET_ELEMENT_REMOVED;
|
||||
|
||||
Environment->postEventFromUser(removeEvent);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//! List of all children of this element
|
||||
|
|
|
@ -400,6 +400,7 @@ void CGUIEnvironment::clear()
|
|||
//! called by ui if an event happened.
|
||||
bool CGUIEnvironment::OnEvent(const SEvent& event)
|
||||
{
|
||||
|
||||
bool ret = false;
|
||||
if (UserReceiver
|
||||
&& (event.EventType != EET_MOUSE_INPUT_EVENT)
|
||||
|
@ -563,7 +564,23 @@ bool CGUIEnvironment::postEventFromUser(const SEvent& event)
|
|||
switch(event.EventType)
|
||||
{
|
||||
case EET_GUI_EVENT:
|
||||
// hey, why is the user sending gui events..?
|
||||
if ( event.EventType == EET_GUI_EVENT
|
||||
&& event.GUIEvent.EventType == EGET_ELEMENT_REMOVED )
|
||||
{
|
||||
if ( event.GUIEvent.Caller == Focus )
|
||||
setFocus(0);
|
||||
|
||||
// TODO: In theory we could also check hovered and ToolTip.Element here.
|
||||
// But not trivial (aka - test *a lot* when you try to change) and not so important.
|
||||
|
||||
if ( UserReceiver )
|
||||
UserReceiver->OnEvent(event);
|
||||
}
|
||||
else
|
||||
{
|
||||
// hey, why is the user sending gui events..?
|
||||
}
|
||||
|
||||
break;
|
||||
case EET_MOUSE_INPUT_EVENT:
|
||||
|
||||
|
|
Loading…
Reference in New Issue