[comp.windows.x] Problem with widgets

markley@celece.ucsd.edu (06/15/89)

I am learning how to program using Xt and have run into a
problem.  I am trying to create a dialog widget and can get
it to work if I use the following.

Widget color_popup;

void create_color_popup(parent)
Widget parent;
{	/* start of color_popup creation */
Arg arg[10];

Widget color_box, red_form;

color_popup = XtCreatePopupShell (
		"color_popup",
		transientShellWidgetClass,
		parent,0,0);

color_box = XtCreateManagedWidget (
		"color_box",
		boxWidgetClass,
		color_popup,0,0);

XtSetArg ( arg[0], XtNlabel, "Enter red value" );
XtSetArg ( arg[1], XtNvalue, 0 );
red_form = XtCreateManagedWidget (
		"red_form",
		dialogWidgetClass,
		color_box,
		arg, 2 );
...
}

This creates a nice little popup with a modifyable text 
field.

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

static Arg	arglist_redform[] = {
	{XtNlabel, (XtArgVal) "Enter red value' },
	{XtNvalue, (XtArgVal) 0 }
};

change call to...

red_form = XtCreateManagedWidget (
		"red_form",
		dialogWidgetClass,
		color_box,
		arglist_redform,
		XtNumber(arglist_redform));

Is this the way that it is supposed to work or am I missing
something?  I have trouble believing that the static
declaration causes that much of a problem.  Sorry for the
length of the posting but I included only what I felt was
important.

Mike Markley
University of California, San Diego
markley@celece.ucsd.edu
markley@kubrick.ucsd.edu
disclaimer:
These opinions are mine.  The University could probably care
less what I say or do.

converse@EXPO.LCS.MIT.EDU (Donna Converse) (06/21/89)

> 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.  

This question may have fell through the cracks -- I'm sure others
could have posted an answer earlier.

Donna Converse
converse@expo.lcs.mit.edu

kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (07/26/89)

> This creates a nice little popup with a modifyable text 
> field.

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

> static Arg	arglist_redform[] = {
> 	{XtNlabel, (XtArgVal) "Enter red value' },
> 	{XtNvalue, (XtArgVal) 0 }
> };

The value field is a string field and should be "0".

Use this arglist instead:

	static Arg arglist_redform[] = {
		{XtNlabel, (XtArgVal) "Enter red value" },
		{XtNvalue, (XtArgVal) "0" }
	};

						Chris D. Peterson     
						MIT X Consortium 

Net:	 kit@expo.lcs.mit.edu
Phone:   (617) 253 - 9608	
Address: MIT - Room NE43-213