Modal dialogbox?

Dear Rooters

Is it possible to create a modal dialogbox?
A modal dialogbox does not only prevent clicking on menus and buttons in the main window,
but also remains the front window until it is closed.

Sorrowly, adding “gClient->WaitFor(fMain)” to the dialogbox constructor is not sufficient,
since it allows the following actions (at least on the Mac):

1, Clicking in the main window brings the main window to front thus hiding the dialogbox.

2, Clicking on the closebox in the titlebar of the main window closes the main window,
but leaves the dialogbox open. Closing the dialogbox thus results in a bus error.

P.S.: The bus error can only be seen in a complex standalone gui application.

Best regards
Christian

Dear Christian,

[quote]1, Clicking in the main window brings the main window to front thus hiding the dialogbox.
[/quote]
I cannot reproduce that on linux. For example, all dialogs in guitest.C remain on top of the main application window even I click on it.

To avoid this you can do in the dialog window constructor:

((TGMainFrame *)(main->GetMainFrame()))->SetBit(kDontCallClose, kTRUE); gClient->ProcessEventsFor(this);
…later in the CloseWindow() method (or somewhere else) of the dialog window remove this setting by:

((TGMainFrame *)(main->GetMainFrame()))->SetBit(kDontCallClose, kFALSE);

Best regards, Ilka
++ Forgot to note that main is the main application pointer over which the dialog pops up

Dear Ilka

Thank you for your reply.
I could solve my first problem by replacing:
new XNewDialog(gClient->GetRoot(), fParentFrame, 480, 200);
with:
new XNewDialog(gClient->GetRoot(), fParentFrame->GetMainFrame(), 480, 200);
It seems that the dialogbox remains in the front only, when TGTransientFrame is
linked to TGMainFrame but not to TGCompositeFrame.

Sorrowly, the second problem remains, since kDontCallClose is protected and
method DontCallClose() seems to have no effect. I am attaching a macro and a
gui application for demonstration purposes. Maybe, I am doing something wrong?

Best regards
Christian
MyGuiDlog.tar.gz (5.76 KB)

Hi Christian,

[quote]It seems that the dialogbox remains in the front only, when TGTransientFrame is linked to TGMainFrame but not to TGCompositeFrame. [/quote] That is a normal behavior because TGMainFrame class takes care about the application and TGTransientFrame class about the dialogs. The TGcompositeFrame is a container class mainly in use for laying out GUI widgets.

[quote]Sorrowly, the second problem remains, since kDontCallClose is protected and method DontCallClose() seems to have no effect.[/quote]There will be no problem to provide methods for doing that. I will see your example on Monday.

Best regards, Ilka