Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!agate!shelby!neon!Hudson.Stanford.EDU!lockheed From: lockheed@Hudson.Stanford.EDU (Lockheed) Newsgroups: comp.windows.x Subject: Re: Proper modal dialogs using Xt -- can it be done? Message-ID: <1990Jul17.143420.13475@Neon.Stanford.EDU> Date: 17 Jul 90 14:34:20 GMT References: <9007070658.AA17967@Larry.McRCIM.McGill.EDU> Sender: news@Neon.Stanford.EDU (USENET News System) Organization: Computer Science Department, Stanford University Lines: 78 >> This question was originally posted in the Motif newsgroup but no one's been >> able to answer it for me so: >> >> 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 >> I previously e-mailed a solution to another person who raised the same question, but I guess I'll post it this time. I'm using HP widgets, but the following piece of code is pure "Xt" and may work for Motif. (Actually the person told me it did work for Motif.) Ik /*****************************************************************************/ static int exit_flag, exit_value; /* dialog_shell should be a popup shell widget */ int modal_dialog(dialog_shell) Widget dialog_shell; { XEvent event; XtAppContext context; context = XtWidgetToApplicationContext(dialog_shell); exit_flag = FALSE; XtPopup(dialog_shell, XtGrabNonexclusive); while (! exit_flag) { XtAppNextEvent(context, &event); XtDispatchEvent(&event); } XtPopdown(dialog_shell); return(exit_value); } /* callback function for the "yes" button */ static void yes_button_action(w, client_data, call_data) Widget w; caddr_t client_data, call_data; { exit_value = TRUE; } /* callback function for the "no" button */ static void no_button_action(w, client_data, call_data) Widget w; caddr_t client_data, call_data; { exit_value = FALSE; } /*****************************************************************************/ ------------------------------------------------------------------------- / | \ | Ik Su Yoo | | | Lockheed AI Center | Office: (415) 354-5584 | | Orgn. 96-20, Bldg. 259 | Fax: (415) 354-5235 | | 3251 Hanover St. | E-mail: ik@laic.lockheed.com | | Palo Alto, CA 94304-1191 | | \ | / -------------------------------------------------------------------------