set derived Window modal

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Faust

set derived Window modal

Post by Faust »

I couldn't figure out how to set a derived window modal. I derived the class IGUIWindow but there is no variable to set the window modal like with the function addWindow. Could someone explain me how to get my own window modal too?


I asked in the beginners help first, but no one could answer my question.

Thanks alot
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

There are no real modal windows. There is simply a big invisible parent gui element when creating a modal dialog. Unfortunately, I forgot to make the creation method of this element public.
Faust

Post by Faust »

Thanks Nico, i'll create my own invisible window or maybe you set your function public.
raveneyex
Posts: 19
Joined: Thu Jul 15, 2010 8:16 am
Contact:

Derived Modal GUI Element

Post by raveneyex »

Hey everyone!

I don't want to create another thread for the same problem so I'm posting in here:

Can somebody explain to me how to make my derived GUI element modal?
I've been reading through the source and I can't seem to find a method or anythin; I also saw that Niko said that it's just a matter of setting one huge invisible parent but I don't quite get it...

Can someone please explain to me how to achieve it or point me out in the right direction?
Any help would be greatly appreciated.
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Wow, reviving a 6 year old thread ^^

And the current solution is that gui-elements don't know themselves if they are modal. Instead you set a modal screen as parent. To do that - first create your element. The add the modal (addModalScreen in IGUIEnvironment) and lastly add your element as child to that modal. And yeah - that strange order is necessary as you can run in rather complex focus troubles otherwise.

You can see some examples of this in CGUIEnvironment.cpp for example in CGUIEnvironment::addWindow.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
raveneyex
Posts: 19
Joined: Thu Jul 15, 2010 8:16 am
Contact:

Worked, but...

Post by raveneyex »

Hey Cute Alien, thanks for answering so fast :D

Anyway, I did what you said and it worked perfectly!!!
The elements now behave like modal windows, but now I have another problem:

I was handling the events of those GUI elements in another gui element that I used to set as parent, but now that the parent is the modal screen, how can I manage those events?

Any idea?

THANKS!!!
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Sorry, I don't get what exactly you try to do there. The idea of a modal is that all gui-events except the one for the modal window are blocked - and that's basically what this modal element does.

Your eventreceiver (the one you set for the device) can still get all normal events.

But maybe just try to explain what you want to reach in the end.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
raveneyex
Posts: 19
Joined: Thu Jul 15, 2010 8:16 am
Contact:

Post by raveneyex »

Ok, I'm gonna try explaining myself (story of my life :P)

I have an event receiver that I use to handle ALL gui events, that's the one I set to the Device.
My derived gui elements have as a parent the rootGuiElement so the eventreceiver can get all of those inputs.
If, by making the derived gui modals I have to change the parent (from rootGUIElement to ModalScreen) is the eventreceiver still able to handle those events?
If so... I have a nasty nasty bug somewhere in my code, cause after I set the derived gui elements as modal, the event handling stopped working.

THANKS, THANKS!
Thans for all your help, you don't know how useful it has been! :D
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Sorry, not sure right now. It looks to me like the modal element does call it's parent and pass the events on except for focus-changes.
Maybe you did not set the parent of the modal to the rootGuiElement?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
raveneyex
Posts: 19
Joined: Thu Jul 15, 2010 8:16 am
Contact:

Post by raveneyex »

Yeah...

I found out what's wrong and just as I thought, it was a nasty programming error.
My bad :oops:

Anyway, thanks again!
:D
Post Reply