[comp.windows.x] Problem with asciiTextWidget callback

zoo@APS1.SPA.UMN.EDU (05/07/90)

I am trying to register a callback with the asciiTextWidget.  I create
the widget, then add a callback with XtAddCallback.  When I execute the
code, I get a message:
   
Warning: Cannot find callback list in XtAddCallbacks

and then the program runs.  Everything works, except that my callback is
never called.

This happens with R4pl4 and R4pl11, on Sun 4 and Sequent Symmetry, cc and
gcc.


Thanks for any help.  If this turns out to be RTFM, please tell me where in
which FM.  I've got the R4 docs and O'Reilly 4 & 5.  This should work, from
what I've read.

david d [zoo] zuhn		Univ. of Minnesota Dept. of Astronomy
zoo@aps1.spa.umn.edu		Automated Plate Scanner	Project


--------------  the code i'm using  -----------------

#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>

#include <X11/Xaw/Command.h>
#include <X11/Xaw/Box.h>
#include <X11/Xaw/AsciiText.h>


#include <stdio.h>


void Text_Callback (w, client_data, call_data)
     Widget w;
     XtPointer client_data;
     XtPointer call_data;
{
  printf ("text changed\n");
}


int main (argc, argv)
     int argc;
     char **argv;
{
  Widget string, top;

  top = XtInitialize (argv[0],
		      "TEst",
		      NULL,
		      0,
		      &argc,
		      argv);


  string = XtVaCreateManagedWidget ("string",
				    asciiTextWidgetClass,
				    top,
				    XtNstring, "test",
				    XtNeditType, XawtextEdit);

  XtAddCallback (string, XtNcallback, Text_Callback, NULL);
 

  XtRealizeWidget (top);
  XtMainLoop();
}

converse@EXPO.LCS.MIT.EDU (Donna Converse) (05/07/90)

> I am trying to register a callback with the asciiTextWidget.  I create
> the widget, then add a callback with XtAddCallback.
>
>  When I execute the code, I get a message:
>    
> Warning: Cannot find callback list in XtAddCallbacks

The Athena asciiText widget is composed of the Text, AsciiSrc, and AsciiSink
widgets.  The callback resource of the asciiText widget is actually a 
resource of the AsciiSrc widget (noted under "callback" in section 5.5.1).

When XtAddCallback is called, no callback resource is found in the
asciiText widget, so your callback is not registered.

Section 5.5 explains that these resources which actually belong to the
AsciiSrc or AsciiSink can be set via XtSetValues, or at widget creation
time (i.e. with XtCreateManagedWidget).  So, the following will work:



  static XtCallbackRec	cb[] = {
      {Text_Callback,		(XtPointer) NULL},
      {(XtCallbackProc) NULL,	(XtPointer) NULL}
  };

  top = XtInitialize (argv[0],"TEst", NULL, 0, &argc, argv);


  string = XtVaCreateManagedWidget ("string",
				    asciiTextWidgetClass,
				    top,
				    XtNstring, "test",
				    XtNeditType, XawtextEdit,
				    XtNcallback, cb);


Donna Converse
converse@expo.lcs.mit.edu

sivagnan@handel.CS.ColoState.Edu (S. Vasanthan) (05/09/90)

 Can you point to me (or provide me with) and example to write an Xaw
application which will display a message in a textwidget window when a
button is pressed. I am having trouble writing to an asciiStringWidget
using XtTextReplace after changing its source with XtTextSetSource().
I am using R3 on Sun3 running Sun OS4.?
--
Vasanthan
Dept. of CS, CSU.