Path: utzoo!attcan!uunet!wuarchive!mit-eddie!bu.edu!orc!decwrl!bacchus.pa.dec.com!shlump.nac.dec.com!shodha.dec.com!clt!schoeller From: schoeller@clt.enet.dec.com (Dick Schoeller) Newsgroups: comp.windows.x Subject: Re: Proper modal dialogs using Xt -- can it be done? Message-ID: <1434@shodha.dec.com> Date: 17 Jul 90 11:56:45 GMT References: <26259@pasteur.Berkeley.EDU> <1990Jul16.190239.7687@maytag.waterloo.edu> Sender: news@shodha.dec.com Reply-To: schoeller@clt.enet.dec.com (Dick Schoeller) Distribution: na Organization: Digital Equipment Corporation, Nausea, Cow Hampshire Lines: 45 > |> This question was originally posted in the Motif newsgroup but no one's been > |> > |> I want to create and display a modal dialog created as a widget under Motif. > |> That is, after I add callback routines, manage & display the widget, I want > |> my main program to wait (without busy-waiting!) until the widget is > |> destroyed and not accept input into its main window while the dialog widget > |> is being displayed. All the dialog examples I've seen so far that use the > |> Xt or Motif widget sets use modeless dialogs. > |> > |> So, can I do this portably using X or do I have to resort to using system > |> calls such as the Unix signalling facility? > |> > |> -- > |> Eric Giguere giguere@csg.UWaterloo.CA > > You need to go through an event processing loop while the dialog is up. This is not entirely true. If you are simply waiting for a required input, you can deal with it as a callback and not use a special "main loop". The XtAddGrab done by the modal dialog box will prevent input going to other widgets than the modal box. This would break the functionality into a "display" procedure and a callback. If, however, you desire a function which displays the box and does not return until the box has been dismissed then Scott Silvey's approach is needed. If you have displayed a modal box while performing a lengthy operation, you can either use your own mini-"main loop" to check the box (if the box has a cancel button) and handle exposures. This would be called occasionally during the lengthy procedure. The result of a "cancel" would indicate that you should clean up and terminate the lengthy operation. If you don't want to allow cancel and are simply using the box as an indicator, you can just call XmUpdateDisplay. This will only process expose events. Dick Schoeller | schoeller@clt.enet.dec.com Digital Equipment Corporation | 603-881-2965 110 Spit Brook Rd., ZKO2-3/R56 | "Either Judaism has something to say to the Nashua, NH 03062-2642 | world or it has nothing to say to Jews." | - Dennis Prager