How to catch event of closing IGUIWindow?

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
Barts_706
Posts: 26
Joined: Tue Nov 01, 2005 1:20 am

How to catch event of closing IGUIWindow?

Post by Barts_706 »

Yet another noob question, I know, I am sorry. *bows ashamed*

I have a GUI in my application now, including some nice window hovering above the main view and displaying some information. Since that information is passed using pointers, it is crucial to make them NULL when user closes the window. My question is :

- how to catch that event (of closing the window, that is) in order to nullify the pointers?

I checked API and the enumeration of event types and I haven't found it (maybe I missed it?). I thought about using general IGUIWindow destructor, but this is not the nicest solution (to use class destructor in order to invalidate some particular pointers).

Do you know how to do that?

I will be very grateful for answers.
Dark Rain
Posts: 47
Joined: Thu Jul 07, 2005 1:31 am

Post by Dark Rain »

It's not supported out of the box, I added the equivalent of WM_CLOSE message the class to make it work.
Barts_706
Posts: 26
Joined: Tue Nov 01, 2005 1:20 am

Post by Barts_706 »

Ouch! So no other way than to implement it by myself? Awww....

But then again, maybe there is some way to block closing of the GUIWindow?

This data is necessary for the program user (it is moreor less scientific program), and it is more convenient to have it in the floating window than some fixed toolbar?
Barts_706
Posts: 26
Joined: Tue Nov 01, 2005 1:20 am

Post by Barts_706 »

I have found solution to my problem, which I give here, even though it is only fit to my particular application (but maybe someone will find it useful).

Before actually sending any data to the toolbox display via pointers, the program simply checks if such an element exists :

Code: Select all

			IGUIElement* toolbox = Device->getGUIEnvironment()->getRootGUIElement()->getElementFromId(5000, true); //5000 is the toolbox id, same as in MeshViewer application example
			if (toolbox ){ then do something}
Sorry to have been bothering you!
zenaku
Posts: 212
Joined: Tue Jun 07, 2005 11:23 pm

Post by zenaku »

Even better:

Code: Select all


s32 closeButtonId = Window->getCloseButton()->getId();

Then, in your event receiver, you can check and see if it's that button or not and do your cleanup code.
Barts_706
Posts: 26
Joined: Tue Nov 01, 2005 1:20 am

Post by Barts_706 »

You're right, I thought about that too, but forgot to write it here.

Thanks for your contribution.
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

Another option you have if you want to get rid of that button completely is:

Code: Select all

Window->getCloseButton()->setVisible(false)
No more close button! I had a window creation function that would automatically do this, and add a Hide Window button to each window instead, to avoid having to re-create the window every time.
Barts_706
Posts: 26
Joined: Tue Nov 01, 2005 1:20 am

Post by Barts_706 »

No, my solution of just verifying whether the window exists before using pointers to the static tex elements contained within works fine for me and I don't want to limit users' freedom by explicitely forbidding them to close the window.

But thanks anyway for your sugestion.
Post Reply