removing ALL gui elements
removing ALL gui elements
hey how can i remove all gui elements but not the gui enviroment?
thanks,
Halan
thanks,
Halan
get the root element with IGUIEnvironment::getRootGUIElement
use getChildren to get a list of all IGUIElements, then remove() to get rid of them. I think children should be removed automatically, but if not you may have to recursively get all children into a list, then remove them in reverse order. read the source to CGUIElement::remove() for clarification.
use getChildren to get a list of all IGUIElements, then remove() to get rid of them. I think children should be removed automatically, but if not you may have to recursively get all children into a list, then remove them in reverse order. read the source to CGUIElement::remove() for clarification.
so i did it like that
but i get a segementation fault
any ideas?
greets,
Halan
Code: Select all
bool deleteGUI()
{
list<IGUIElement*> childlist = env->getRootGUIElement()->getChildren();
list<IGUIElement*>::Iterator it = childlist.begin();
IGUIElement* dummyelement;
for(int i = 0; i < childlist.getSize(); i++)
{
dummyelement = *it;
dummyelement->remove();
it++;
}
};
any ideas?
greets,
Halan
My Blog: http://www.freakybytes.org
yeah i think youre right but again im not so into lists and dont really know how to do it. i tried this but its in some way the same ^^
greets,
halan
Code: Select all
bool deleteGUI()
{
list<IGUIElement*> childlist = env->getRootGUIElement()->getChildren();
IGUIElement* dummyelement;
for(int i = 0; i < childlist.getSize(); i++)
{
dummyelement = *childlist.begin()+i;
if(dummyelement)
dummyelement->remove();
}
};
halan
My Blog: http://www.freakybytes.org
You are deleting the GUI in function. I don´t see eny parameters importing IGUIEnvironment-pointer to function. Is the env-pointer global and you have 100% sure that it isn´t NULL-pointer?? I´d do this function with one parameter:
You can do the same check for iterator than I did for Environment. Or the easiest way is using debugger.
Code: Select all
bool deleteGUI(IGUIEnvironment* env)
{
if(env) // lets check that pointer is not NULL
{
list<IGUIElement*> childlist = env->getRootGUIElement()->getChildren();
list<IGUIElement*>::Iterator it = childlist.begin();
IGUIElement* dummyelement;
for(int i = 0; i < childlist.getSize(); i++)
{
dummyelement = *it; // you can do also a check that iterator isn´t pointing to NULL
dummyelement->remove();
it++;
}
}
};
Dattebayo!!
no it isnt pointing to null cause it works like that (of course only one element is removed).
but i think stodge is right, when i delete the element the iterator becomes invalid. so ive no idea how to do it instead...
Code: Select all
bool deleteGUI()
{
list<IGUIElement*> childlist = env->getRootGUIElement()->getChildren();
IGUIElement* dummyelement;
list<IGUIElement*>::Iterator it = childlist.begin();
dummyelement = *childlist.begin();
if(dummyelement)
dummyelement->remove();
};
My Blog: http://www.freakybytes.org
-
- Posts: 2
- Joined: Sun Aug 13, 2006 6:11 pm
I use this, and it seems to work...
Code: Select all
bool deleteGUI()
{
core::list< gui::IGUIElement * > childlist = env->getRootGUIElement()->getChildren();
while( !childlist.empty() )
(*(childlist.getLast()))->remove();
return true;
}
damit it doesnt work well if i do it like that 4 (and thats really confusing me) GUI elements will be removed
something is really going wrong here...
greetings,
halan
edit: atm ive a workaround with an array wich contains the pointers...
but i dont like it
edit2: maybe this i related to my guielements not having a background e.g. the listbox
Code: Select all
bool deleteGUI()
{
list<IGUIElement * > childlist = env->getRootGUIElement()->getChildren();
return true;
}
greetings,
halan
edit: atm ive a workaround with an array wich contains the pointers...
but i dont like it
edit2: maybe this i related to my guielements not having a background e.g. the listbox
My Blog: http://www.freakybytes.org