[comp.windows.x] Creating a Blocking Message Box --- RESULTS

arthur@media.uucp (Art Poley) (08/17/90)

First, I'd like to thank all of you who replied to my original posting.
The majority seems to agree on the following implementation:

1) Via a call to XmCreateMessageDialog, create the message box with the desired
	button and message labels.  I also set the dialogStyle type to
	XmDIALOG_APPLICATION_MODAL to cause ALL input to be fed directly
	to the message box.
2) Establish a callback that will be used to receive the user's button 
	actuations (reply) from the message box.  This callback routine 
	will set a global variable used to hold the user's reply.
3) Formulate your own XtMainLoop to get and dispatch events until the user
	has made a reply.  
4) Once the reply has been made, and the main loop "emulator" has been 
	exited, process the reply status.


This solution does have its deficiencies.  I implemented the above method
with a subroutine that returned the status of the user's reply to the caller.
Often this routine was invoked from within a button callback procedure.  The
routine would be called, reply returned, and then the button that was 
responsible for the call would be left in a irregular state once back 
inside XtMainLoop.  By irregular I mean that if the mouse pointer were to be
dragged over the button, the button image would toggle between 
pressed/unpressed.  Note this would not cause the underlying callback to
be reinvoked, only the image changed.  Anyway, the end result was that the
XtMainLoop emulation would cause the button release event to be discarded.
Since the MODAL was set in a way to grab all input, the message box would
receive the underlying applications button release event and discard it.
By a somewhat gross modification to the emulation loop, it is possible to
preserve those events that may not belong to the message box.  Basically,
my fix entailed monitoring the events and if a Release event was found 
before any Press events from the message box, then that event belonged to
the underlying application and would be held off to the side and before
leaving the subroutine, pushed back onto the event queue.

Thanks again and good luck!

-- 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Art Poley - Media Cybernetics		Phone: (301)495-3305
Internet: arthur%media@uunet.uu.net 	UUCP: {uunet,hqda-ai}!media!arthur

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++