Page 1 of 1

Modal Windows

Posted: Tue Dec 06, 2005 01:54
by spannerman
Hola,

Ive discovered the setModalState function, and I think that this could be quite useful if it is what I think it is. But what exactly is it? :P

The comments say that if I pass true in as an argument when calling this function on a window then "this Window will be activated and set as the modal target."
Ive done just this as a quick test, but it doesnt seem to do anything. I think my understanding of a modal window in this context is not quite right: if a window is modal, then only this window will be active i.e. continue to receive events, and all other windows in the system will be inactive. Am I on the wrong track here?

Re: Modal Windows

Posted: Tue Dec 06, 2005 07:05
by lindquist
Setting a window's modal state to 'true' should ensure that only this window and it's children will be able to receive input events.

It can be used to create dialogs that require input before allowing use of the rest of the gui again etc..

Re: Modal Windows

Posted: Thu Dec 08, 2005 13:37
by spannerman
Sorry, lindquist, this question was a waste of time. Going back to my original test I did with this modal window functionaity, I see that it IS actually working :roll:

Dunno why I thoughht it wasnt! Sorry :hammer:

Posted: Sat May 20, 2006 06:08
by Gaal
The "Modal" functionnality works just until another modal window is opened then closed.

Here is the problem I encountered :
First please excuse my English, this is not my mother language!

I have a set of cascading windows making some configuration setting:
Window0 : containing some buttons calling several windows let's say Button1 calling Window11, button2 calling Window12, etc...

Window11 : also containing buttons calling other windows (21, 22, etc...)

All of these windows are set Modal when they are called.

Here is what I noticed :

Firstly: Window0 calls Window11.
Then Window11 calls Window21
So I have such a cascade :

Code: Select all

Window0
   |----Window11  (modal)
           |----Window21 (Modal)

When I close Window21, Window11 is no longer modal !
This is verified by accessing all buttons from Window0 !!! and the worst of that, Window0 can be closed leading to an orphan Window11 that makes the program to crash besause Window0 is not there !

Has anybody already noticed this?
Does anybody have a solution?

Looking forward to hearing good news from you :wink:

Gaal

Posted: Mon Sep 11, 2006 13:10
by franckypoune
I also notice this problem.
Someone have a solution for this?
Thanks

Posted: Mon Sep 11, 2006 13:22
by lindquist
you could implement your own modal stack

Posted: Mon Sep 11, 2006 14:03
by franckypoune
That 's to say , i manage a dialog list where when you add a new dialog in it, you set the flag Modal state to true and the previous to false?

Posted: Mon Sep 11, 2006 14:42
by nebukadnezzar
when you open Window21

call Window11->setModal(false)




and when you close window21

call Window11->setModal(true)

... this should do it i think....

Posted: Mon Sep 11, 2006 17:02
by Rackle
You could give Dialog System a try; it does more than simply code the ok-cancel-apply behaviors. The dialog portion may provide the functionality you are seeking.

Posted: Mon Sep 11, 2006 20:37
by franckypoune
I create a manager (singleton) which manages a list of modal window anf it works fine.

When i add a new window in the list:
the last one in the list lose the modal flag and the new has the modal flag
and when a window is destroyed, this window is removed from the list and set the modal flag to the last window of the list.

Thanks for your help

Posted: Mon Sep 11, 2006 20:46
by franckypoune
for dialog box (message box windows like), i create a window which has in its constructor a pointer on a result function.
This function sets data in a structure (argument of the function) when the user clicks on one button (YES, NO, OK ,CANCEL)
The parent of this window tests if the action is finished (tests the data of the structure which contains the action result (OK,NOT_DONE)) when its receives the event RendererStart.
I don't know if i am clear on my explanation, sorry it is late...
And i want to know if it is ok to use this method?