[comp.windows.x] blocking and X

lampshir@airgun.wg.waii.com (gregory b. lampshire) (07/11/90)

Greeting peoples....

I am hoping that all you Motif  experts out there can help me on a
small problem I am having.  What I wish to do is create an application
modal, blocking yes/no widget.  Let me explain.

I am writing a program that must ask alot of yes/no questions.  These
questions are critical and hence, the program cannot continue without
them.  What I would like to do is use the following code segment

Boolean answer;
...
answer = DoNotReturnWithoutAnswer("Do you want to continue?");
...

to return an answer.  However, in the event driven environment, even
with the widget's dialog type set to application modal, the func
'DoNotReturnWithoutAnswer' returns before the user can respond.  The
yes/no widget, however, is left displayed waiting for the user in an
event driven manner.

What I really need is to block until the user responds, could someone
give me some skeleton code to show me how to do this?  The sequence of
events should be thus....
  
1) call the yes/no func
2) popup a small window with the question string as the display string
3) create a yes and a no push button
4) block and grab the pointer (confined to the yes/no window box)
until the user responds
5) return either True or False

I have made some progress.  Using Intrinsics and the XtPopup() group
of funcs I can make the widget popup (without any fancy borders which
is what I wanted anyway) and display the two push buttons with label
string.  No problem.  I even grabbed the pointer.  However, the event
loop necessary for the blocking action is still alittle beyond me.
How about some help?

I know someone has already written something similar (I think
in the UK group) but did it do blocking.  I would appreciate
someone sending me the source if they have it.  Please do not
flame me if this issue has been brought up many times before,
I am a new reader of this newsgroup.



gregory lampshire     | Searching for a computer which can do it
western geophysical   | all......
-- 
Gregory B. Lampshire     |    DOMAIN lampshir@airgun.wg.waii.com
Western Geophysical      |    UUNET  uunet!airgun!lampshir

mouse@SHAMASH.MCRCIM.MCGILL.EDU (der Mouse) (07/11/90)

> What I wish to do is create an application modal, blocking yes/no
> widget.  Let me explain.

> I am writing a program that must ask alot of yes/no questions.  These
> questions are critical and hence, the program cannot continue without
> them.  [...]  The sequence of events should be thus....

> 1) call the yes/no func
> 2) popup a small window with the question string as the display string
> 3) create a yes and a no push button
> 4) block and grab the pointer (confined to the yes/no window box)
>    until the user responds
> 5) return either True or False

Strictly as a user interface design question, I would think hard about
number 4.  Preventing the user from moving the mouse around to use
other programs seems to me to be excessively draconian.

Preventing the user from doing anything else *within your application*
is not what I am questioning.  What I dislike is preventing the user
from doing things with *other* applications.  Grabbing the mouse and
confining it to the yes/no box won't *necessarily* do this, but will
for anyone using a PointerRoot style focus model, which is certainly
common enough.

(I haven't a clue about implementation, regardless, sorry.)

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

victoria@sbi.UUCP (Victoria Drozdov) (07/12/90)

In article <860@airgun.wg.waii.com>, lampshir@airgun.wg.waii.com (gregory b. lampshire) writes:
>  ...
> I am writing a program that must ask alot of yes/no questions.  These
> questions are critical and hence, the program cannot continue without
> them.  What I would like to do is use the following code segment
>  ...

All you need is to use a Motif modal dialog box.
Just set the XmNdialogStyle to XM_DIALOG_APPLICATION_MODAL.

jelarcic@csusac.csus.edu (Mikey Jelarcic) (07/13/90)

In article <860@airgun.wg.waii.com> lampshir@airgun.wg.waii.com (gregory b. lampshire) writes:
>them.  What I would like to do is use the following code segment
>
>Boolean answer;
>...
>answer = DoNotReturnWithoutAnswer("Do you want to continue?");
>...
>
>to return an answer.  However, in the event driven environment, even


  Here's a possible solution, create a modal dialog box with the yes/no
buttons.  the activate callbacks (I'm speaking X here, not Motif but
the solution should on Motif) of the buttons should set a variable to
a certain value.  In your DoNotReturnWithoutAnswer routine you should
set this variable to a known value (not a value assocated with a button),
bring up your dialog box and process events until the variable changes
its value.  I have used this method extensively for the software the
company I work for makes.
-- 
Michael L. Jelarcic					..!csusac!jelarcic
	"Who said what?!?  Never heard of him, go away." - my employer