[comp.windows.x.motif] Help for modal windows needed

harper@applga.aa.cad.slb.com (Brett E. Harper) (10/31/90)

hello,

  Does anyone know of a good way to acheive modal input focus under motif?
What I want is when a modal dialog box comes up, that it should lock out input
to any other windows within the application.  I have been trying to use the
APPLICATION_MODAL feature of the dialog widget, but I have just been recently
told that our implementation of Motif does not consider the entire application
tree as being locked out.  I guess the only window that is locked out is the
primary window (the parent) of the window that is now application modal.  

  This does not help me any I would like to see lock out on every window within
the application.  Suppose I had a hierarchry like this:


             TopLevel
           |          |
     InfoWindow    MainWindow
     |  |...|
     P1 P2  Pn

  where, Px is a DialogShell that can either be modeless or modal.
  note, only one modal DialogShell will be on screen at any one time.

  Say P1 is modal, then I would like to lock out input to P2,...,Pn,InfoWindow,
   and MainWindow until P1 is undisplayed.


 Does anyone know of a way to do this?  

 The version of MOTIF that I am using is 1.0 implemented on a HP9000s400


 I would really appreciate any help that I can get on this subject.
 
 Thanks,

 Brett Harper

 harper@aaaca1.SINet.SLB.COM

db3l@ibm.com (David Bolen) (11/01/90)

In article <1990Oct30.182737.1219@applga.aa.cad.slb.com> harper@applga.aa.cad.slb.com (Brett E. Harper) writes:

>  Does anyone know of a good way to acheive modal input focus under motif?
>What I want is when a modal dialog box comes up, that it should lock out input
>to any other windows within the application.

I'm not sure it's the best solution, but what I ended up doing to accomplish
this myself was to turn off the sensitivity of the windows affected by the
modal dialog box, via XtSetSensitive(widget,False).

For my case, I just issued this on the shell widget that was the top level
of my tree, which also blocked any children.  And if you have a menu on the
window, it adjusts to show that it is now insensitive, so the window at least
shows some indication of being locked.

When the dialog goes away, just reenable the sensitivity.

> This does not help me any I would like to see lock out on every window within
>the application.  Suppose I had a hierarchry like this:
>      TopLevel
>    |          |
>     InfoWindow    MainWindow
>     |  |...|
>     P1 P2  Pn
>where, Px is a DialogShell that can either be modeless or modal.
>note, only one modal DialogShell will be on screen at any one time.
>Say P1 is modal, then I would like to lock out input to P2,...,Pn,InfoWindow,
>and MainWindow until P1 is undisplayed.

I'd try the XtSetSensitive on your TopLevel.  Of course, you'll have to make
sure that your popup that is modal is not a child of the window you are
disabling the sensitivity of, but since most popups have their own transient
shell, that shouldn't be too hard to set up.

Of course, if the modeless dialogs also have their own transient shell that
is not a child of TopLevel (or InfoWindow), you'll have to disable them
explicitly in addition to TopLevel.

-- David
--
/-----------------------------------------------------------------------\
 \                             David Bolen                             /
  |    Laboratory Automation, IBM Thomas J. Watson Research Center    |
 /              P.O. Box 218, Yorktown Heights, NY  10598              \
| - - - - - - - - - - - -  M i t h r a n d i r  - - - - - - - - - - - - |
| Internet : db3l@ibm.com                    | Bitnet : db3l@yktvmv     |
| Usenet   : uunet!bywater!arnor!larios!db3l | Phone  : (914) 945-1940  |
\-----------------------------------------------------------------------/

boote@bierstadt.scd.ucar.edu (11/06/90)

In article <1990Oct30.182737.1219@applga.aa.cad.slb.com>, harper@applga.aa.cad.slb.com (Brett E. Harper) writes:
>   Does anyone know of a good way to acheive modal input focus under motif?
> What I want is when a modal dialog box comes up, that it should lock out input
> to any other windows within the application.

Try using XtAddGrab on the widget you want to keep the focus.  One of the
parameters is the type of grab (exclusive etc.).  You will however need to
do an XtRemoveGrab on the widget when you are done with it.

>  Brett Harper
> 
>  harper@aaaca1.SINet.SLB.COM

-- 
Jeff W. Boote                   SCD/NCAR
boote@ncar.ucar.edu           Boulder, Colo

glp@ibism.UUCP (Greg Parkinson) (11/07/90)

>   Does anyone know of a good way to acheive modal input focus under motif?
> What I want is when a modal dialog box comes up, that it should lock out input
> to any other windows within the application.
> 

I get this to work using a BulletinBoard as the child of a DialogShell,
and setting the dialogStyle attribute DIALOG_APPLICATION_MODAL.  Works
like a charm.

Has anyone else used this?  I want to change this dynamically after the
window has been displayed, so that I can pop up a new modal window and
give it focus, while leaving the first on on the screen.


-- 
Greg Parkinson               Phone:  212-657-7814
Citibank                     Fax:    212-657-0068
111 Wall Street              E-Mail: uunet!ibism!glp
New York, NY  10043
The opinions expressed are my own and not those of Citibank/Citicorp.

achan@sparkle.nec.com (Amy Chan) (11/07/90)

In article <9093@ncar.ucar.edu> boote@bierstadt.scd.ucar.edu () writes:
>In article <1990Oct30.182737.1219@applga.aa.cad.slb.com>, harper@applga.aa.cad.slb.com (Brett E. Harper) writes:
>>   Does anyone know of a good way to acheive modal input focus under motif?
>> What I want is when a modal dialog box comes up, that it should lock out input
>> to any other windows within the application.
>

Some dialog boxes (e.g. XmBulletinBoard, XmMessageBox) have a resource 
called XmNdialogStyle which you can set to XmDIALOG_APPLICATION_MODAL to 
lock out input to any other windows within the application.

Amy Chan
NEC America, Inc.
achan@tdd.sj.nec.com

nazgul@alphalpha.com (Kee Hinckley) (11/07/90)

> I get this to work using a BulletinBoard as the child of a DialogShell,
> and setting the dialogStyle attribute DIALOG_APPLICATION_MODAL.  Works
> like a charm.
> 
> Has anyone else used this?  I want to change this dynamically after the
> window has been displayed, so that I can pop up a new modal window and
> give it focus, while leaving the first on on the screen.

I believe that APPLICATION_MODAL is supposed to lock out only parents
uncles and aunts, but not siblings.  However I'm a) not positive about this
and b) don't think it works until 1.1.  Can someone clarify that?

				-kee

paul@ixi.uucp (Paul Davey) (11/13/90)

In article <901106171521.7936@alphalpha> nazgul@alphalpha.com (Kee Hinckley) writes:

   > I get this to work using a BulletinBoard as the child of a DialogShell,
   > and setting the dialogStyle attribute DIALOG_APPLICATION_MODAL.  Works
   > like a charm.
   > 
   > Has anyone else used this?  I want to change this dynamically after the
   > window has been displayed, so that I can pop up a new modal window and
   > give it focus, while leaving the first on on the screen.

   I believe that APPLICATION_MODAL is supposed to lock out only parents
   uncles and aunts, but not siblings.  However I'm a) not positive about this
   and b) don't think it works until 1.1.  Can someone clarify that?

It works at 1.0, but relies on Mwm to be running. Mwm assigns
focus to the dialogs popped up and refuses to set it elsewhere.

1.1 corrects this behaviour by using XtAddGrab in the toolkit, as
opposed to assuming that all Motif applications will be running under
Mwm.

You can use XtAddGrab with 1.0 to get the proper behaviour.

XtAddGrab is designed to work with cascades of widgets be these sub
menus or dialog boxes popped up from dialog boxes.
 
XtAddGrab has a flag to allow previous widgets in a cascade to be
excluded from a new `grab'.  (This `grab' is not an X grab, it's done by
the dispatcher within the intrinsics, ie at the client end).
--
 Regards,			 pd@x.co.uk          IXI Limited
	Paul Davey		 pd@ixi.uucp         62-74 Burleigh St.
				 ...!uunet!ixi!pd    Cambridge  U.K.
 "These are interesting times"   +44 223 462 131     CB1  1OJ