Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!purdue!bu-cs!bloom-beacon!EXPO.LCS.MIT.EDU!converse From: converse@EXPO.LCS.MIT.EDU (Donna Converse) Newsgroups: comp.windows.x Subject: Re: help (with a popup prompt design) Message-ID: <8908151941.AA26642@expo.lcs.mit.edu> Date: 15 Aug 89 19:41:06 GMT References: <3982@ncar.ucar.edu> Sender: daemon@bloom-beacon.MIT.EDU Organization: X Consortium, MIT Laboratory for Computer Science Lines: 32 > I want to have a generic warning routine, call it display_warning(), > that when invoked will popup and display a warning message > (under the Xt instrinics) and require the user to select a proceed or > cancel button. The problem > is that I want display_warning() to return a value depending on the > user's selection. How do I get display_warning() to wait until a selection > has been made before returning?. I think the programming model for control flow needs to be changed from a computational one to an event driven model. The user is out there doing stuff that causes your program to get notification of events. Your program cannot control or anticipate the order of events, or the timing between events. Instead, your code is a collection of responses to events, with callbacks and client data and some global variables as "chewing gum and paperclips" holding it all together. When you (the application programmer) popup the warning, you can't block at the next line of code waiting for the user to press a button. You probably already understand this, at least intuitively. Consider how the application processes events -- XtAppMainLoop, usually. After you popup the warning, let the control return to the main loop. Otherwise, what is going to process the event of the user pushing a button in the popup? The problem of knowing which button was pressed can be solved by registering a different callback procedure with each button in the popup, or by giving each button different data to pass to a single callback. The confirm callback can actually do the body of the computation, the work requested. Donna Converse converse@expo.lcs.mit.edu