Clearing the GUI

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
November235
Posts: 15
Joined: Thu Dec 04, 2003 11:09 am
Location: London UK
Contact:

Clearing the GUI

Post by November235 »

Is there a way to clear all the elements I've added to an IGUIEnvironment in one command? As far as I can see, I have to keep pointers to all my elements and then remove them individually, which is something I'm not too keen on doing :).
November235 - Are you in FINAL DENIAL?
Land - Air - Sea
November235
Posts: 15
Joined: Thu Dec 04, 2003 11:09 am
Location: London UK
Contact:

Post by November235 »

Meh. I guess storing them in a pointer array won't be that bad... there aren't that many :).
November235 - Are you in FINAL DENIAL?
Land - Air - Sea
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

Im not sure cause I'm new to IRR, but have you tried putting the element you want to clear into a IGUIWindow? (ie: create an IGUIWindow, and when you create those elements, set it as their parent)

When you delete the window, perhaps it clears it's children elements? Not sure..
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

You could get "getRootGUIElement()'s" Children from the Children list and removeChild() them.
Crud, how do I do this again?
rt
Posts: 150
Joined: Sun Nov 30, 2003 6:54 am
Location: canada
Contact:

gui gui everywhere but not a drop to drink

Post by rt »

or you could add this function to IGUIElement.h

Code: Select all

	//! Removes All Children
	virtual void removeChildren() {
		// delete all children
		core::list<IGUIElement*>::Iterator it = Children.begin();
		while (it != Children.end()) {
			(*it)->Parent = 0;
			(*it)->drop();
			it = Children.erase(it);
		}
	}
then call

Code: Select all

void ClearGui() {
	irr::gui:: IGUIElement* ele = grr.env->getRootGUIElement();
	ele->removeChildren();
}
from your project
Post Reply