How to force focusing on a popup dialog (TGWindow) until some events happen?

Hi ROOTers,

I am working on a GUI for CAEN Digitizer and it is necessary to have a reliable error handling.
Particularly, If an error occurs I popup a dialog window (see pic). For several reasons I need to force focus on that popup error window until OK button clicked. So is there a simple way to do that? Of course, I could write a function that would disable all widgets on a background window but it is not very good solution.

1578849137_0012_13012020_640x317

UPDATE

Here is my implementation of error dialog. It is a class named ErrorDialog. I think its constructor explains what is going on.

ErrorDialog::ErrorDialog( const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, const caenoo::CAENException& e, const std::string &msg )                                                               
{
    fMainFrame = new TGTransientFrame( p, main, w, h );
    fMainFrame->Connect( "CloseWindow()", "ErrorDialog", this, "CloseWindow()" );
    fMainFrame->DontCallClose();
 
    fMainFrame->SetCleanup( kDeepCleanup );
    //Create button and text
    CreateBottomFrame();
    CreateInfoFrame( e, msg );
 
    fMainFrame->MapSubwindows();
    fMainFrame->Resize();
 
    // position relative to the parent's window
    fMainFrame->CenterOnParent();
 
    fMainFrame->SetWindowName("Error");
 
    fMainFrame->MapWindow();
}


ROOT Version: 6.04.00
Platform: SL7
Compiler: gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)


OK. Two things. First of all, I realized that have not provided enough information about my error dialog. Post edited. Second of all, I think the problem is solved with using TGMsgBox dialog. It seems that it does what I want. However, if a popup dialog is more complicated than just a message with a button TGMsgBox is not enough. So I would like to leave the question opened.

You’re correct, TGMsgBox is the right choice. And then, if you want to wait for a widget to be closed, use:

   gClient->WaitFor(this);

with this being the widget

Thank you. It works.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.