@begin(header)
author: Mark S. Ackerman
show_author: ShowNone
author_organization: MIT Center for Coordination Science
node_expert: ackerman=ag@ics.uci.edu
expiration_date: 12/31/93
last_modifier: ackerman@ics.uci.edu
last_mod_date: 08/27/91
mod_num: 2
@end(header)
@begin(M)
Subject: How to use the Dialog Widget more effectively. 
Date: Fri, 16 Dec 88 15:22:02 EST
From: Chris D. Peterson 


Here is some general information about the Athena dialog widget.

This widget is composed of several sub widgets, and sometimes is
is necessary to go in and work with these values to get the exact behavior
that you would like.  

The dialog widget it self is a subclass of the form widget, and has all
the properties of a form.  The advantage to using the dialog is that is
comes with some free children.

Always:						Label Widget: 	name "label"
If you specify a value then you also get: 	Text Widget: 	name "value"
and, of course, any buttons add with XtDialogAddButton().

		     dialog

	/	/	|	\	\

     label    text     button1   button2 .......

By using the function XtNameToWidget() with a starting search point of the
dialog widget you have the means to go a get the widget id's for each of
the children of the dialog.

Here are a few examples of what this allows you do do.


> Subject: Novice vs. Xaw Dialog Widget

> Everything works just ducky, except I can't figure out
> how to clear the value area in the widget after the user has hit either
> "cancel" or "confirm".			

Do an XtTextReplace on the string in the text widget using the id
retrieved by the above method.


> Subject: Form widget question

> Are there any plans to add an XtNorientation resource to the Dialog
> widget?  It would be handy to be able to specify a Dialog like

This is already there, just change the constraint resources on the text
widget to:

XtNfromVert	NULL
XtNfromHoriz	label widget id.

This can all be done, once you have the widgets id's.


> Subject: Xt/Xaw question

> Is it possible for a client to set the `font' resource of the label
> widget contained in a dialog widget (or, in general, any resource
> of the sub-widgets created by a dialog)?

Just like a normal label widget, once you have the label's id number,
Use XtGetValues.
						Chris D. Peterson     
						MIT X Consortium /
						Project Athena 

@end(M)

@begin(M)
Subject: Re: Dialog Widget 
Date: Thu, 29 Dec 88 15:24:29 EST

> Thanks for the info on the Dialog widget!
> One other question -- how is the value of XtNwidth used? 

Both the Athena Dialog and the Athena Form widget ignore their width
and height arguments.

Since the Dialog is a sub_class of the form if you want to know exactly how 
either of these will be layed out consult the Xt Athena Widget Set
documentation on the Form widget.  I also posted a message to xpert 
about a week ago on this topic.

						Chris D. Peterson     
						MIT X Consortium /
						Project Athena 
@end(M)

@begin(M)
Subject: Re: probs with popup windows 
Date: Fri, 05 May 89 12:11:35 -0400


> My latest idea is to have a dialog widget within a popup shell...

Who's latest idea? :-) :-)

> I'm having great difficulty getting things to work as stated above.

It sounds like you are having problems with your program flow.  What you
need to do is:

1) When this user selects display popup the dialog widget, and then return from
   the routine.

This will return you to XtMainLoop() which will process events and
popup the dialog widget.

2) If cancel is selected then just popdown the dialog, and then exit.
   This will cause no other action (the desired behavior.

3) If "okay" was selected then check the barcode.
   a) If it is okay then call your computation routine right here in the
      okay proc.

   b) If is it not okay then print an error message and force the user to 
      try again (or whatever.


It is important to remember that no event processing will happen when
the program is actually in a callback or action routine, all event processing
and window operations take place when the program is in the XtMainLoop() 
fuinction.  It is important to spend as little time away from this routine
as possible, as no events will be processed while you are off doing something
else.  This includes both user interactions and window refreshes.

> A few other minor questions:  Is there a way to set the font for the
> text entered by the user in the dialog widget (XtNvalue)?

The name of the dialog widgets value entry widget is documented as: "value"
Thus you can use a resource specification of the following:

*<dialog name>*value.Font:		<font_name>

If you really want to hard code the font name into the program (very bad
practice IMHO) you can use XtNameToWidget() to get the widget id of the the
value widget and then do a XtSetValues().

>  Am I correct to be using XtGrabExclusive as an argument to XtPopup?

It depends upon the behavior that you desire,  XtGrabExclusive will lock out
event processing in the rest of your application while the grab is active
(as long as the menu is up).

> If I use XtNvalue with the dialog widget, then I don't need
> XtGetValueDialogString, correct?

Nope, you should use XtGetValueDialogString(), as the dialog value is
copied internally.  It is not clear that this is the right behavior, but
it seems too late to break things.

						Chris D. Peterson     
						MIT X Consortium /
						Project Athena 
@end(M)

@begin(M)
From: Donna Converse
Subject: Re: Problem with widgets 
Date: Tue, 20 Jun 89 14:43:45 -0400


> I am trying to create a dialog widget and can get
> it to work if I use the following.

  [dialog label and value resources set with the XtSetArg macro]

> If I do it the following way all I get is the title with
> no text field.

  [same resources set to same values using a statically initialized 
  argument list.]


To have the dialog box include an area into which the user types
input, the value of the dialog resource XtNvalue must be non-NULL.
I cannot explain why, nor duplicate, specifying
	XtSetArg ( arg[1], XtNvalue, 0 );	
and getting a dialog box with an editable text area.

If you want the initial string displayed in the text area to be 
the empty string, specify 
	XtSetArg( arg[1], XtNvalue, "");
or the equivalent in static form.  

Donna Converse
@end(M)

@begin(Q)
Date: 7 Aug 89 07:48:38 GMT
Subject: DialogWidget problems

While using the dialogWidget, I find that if I change the
value string after  the widget is realized, using
XtSetValues on XtNvalue, then while the dialog box displays
the new string, I never get back the new value that's been typed
in using XtDialogGetValueString().
Any ideas?.
@end(Q)

@begin(A)
Subject: Re: DialogWidget problems 
Organization: X Consortium, MIT Laboratory for Computer Science
Date: Mon, 07 Aug 89 20:47:03 -0400

> While using the dialogWidget, I find that if I change the
> value string after  the widget is realized, using
> XtSetValues on XtNvalue, then while the dialog box displays
> the new string, I never get back the new value that's been typed
> in using XtDialogGetValueString().
> Any ideas?.

Do you print out the string that XtDialogGetValueString returns,
or are you using it to set the label?   If the label string is in
volatile memory, and you are using XtDialogGetValueString to get
something to set the label, it could lead you to think that the 
problem is with the value.  

Donna Converse
@end(A)

@begin(M)
Subject: Re: A MAC dialog implementation 
Organization: X Consortium, MIT Laboratory for Computer Science
Date: Mon, 07 Aug 89 11:38:33 -0400


> I am trying to
> imitate the Mac look-and-feel for a dialog box.  When the box pops up I want
> the users input focused to the text widget of the dialog widget.

If your mouse pointer is within the bounds of the dialog box, the keyboard
input will be directed to the text value widget in the dialog box.
If you want user input to the rest of your application to be ignored while the
dialog box is up, you can use XtGrabExclusive in the popup call, instead of
XtGrabNone.  If you want still stronger medicine, you must be intending that
your application will prevent user input to other applications on the screen.
In that case, refer to the Inter-Client Communications Conventions Manual.

> Well how do I obtain the text
> widget of the dialog widget without dipping into the Private stuff????

The instance name of the Dialog's text widget is given on page 39 of the
Athena widget documentation.  You can use XtNameToWidget to get what you need.

> 	Another nice featrue that I would like to implement is when the 
> return key is pressed it will invoke the "confirm" button attached to the 
> dialog widget.
> That is when return is pressed
> I will call a routine that will then invoke the callback associated with the
> "confirm" button.  

Write an action routine which calls your confirm callback routine, declare an
action table and register it with the translation manager.  Create an
application defaults file for your application, if you don't already have one,
and put your event translation in it.  Suppose Demo is your app class.

Demo*Dialog.value.translations: #override\n\
	<Key>Return: confirm-action()\n


Donna Converse

Organization: X Consortium, MIT Laboratory for Computer Science
Date: Mon, 07 Aug 89 11:59:50 -0400

In my previous message, I erroneously claimed:
	
> If your mouse pointer is within the bounds of the dialog box, the keyboard
> input will be directed to the text value widget in the dialog box.

A blatant lie, in R3.  Use XtSetKeyboardFocus to get this effect.


Donna Converse
@end(M)

@begin(M)
Subject: Re: The dialog widget 
Date: Fri, 03 Nov 89 08:34:30 -0500

> Is there a way to update the "value" in the dialog widget after it has been
> initially defined ?? 

SetValues on the "value" resource does not work in R3, this has been fixed for
R4, and when that release is avaliable this problem should go away.

Until then here is the only solution:

1) Use XtName to widget to retreive the widget id of the child of the dialog
   whos name is "value".

2) Use XtTextReplace to change the string in this widget.

This method should continue to work in later releases, although if XtSetValues
worked it would be much cleaner.


						Chris D. Peterson     
						MIT X Consortium 

@end(M)

