Path: utzoo!attcan!uunet!wuarchive!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!bloom-beacon!VUSE.VANDERBILT.EDU!wjhagins From: wjhagins@VUSE.VANDERBILT.EDU (William J. Hagins) Newsgroups: comp.windows.x Subject: Trouble with Tribbles Message-ID: <8910271950.AA03865@cs7> Date: 27 Oct 89 19:50:25 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 145 I am trying to "clear" a text widget. The example code does so upon activation of the button, but I also have a problem which I can not solve. After the text is cleared, if you try to retype into the text window, after the first character is typed, a '@' character comes up (apparantly the null character. This does not happen if you click the mouse in the window before typing. I am stumped, aand would like help. The code follows, along with the header file. Thank You -Jody. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "fontdef.h" Arg args[20]; int n=0; FILE *outfile; char outfileName[] = "RE.DAT"; Widget toplevel = NULL; Widget quitButton = NULL; Widget acceptButton = NULL; Widget clearButton = NULL; Widget Scroller1 = NULL; Widget Form1 = NULL; Widget w1; char s1[30] = ""; /* *** check for the validity of the string definitions. maybe accessing wrong addresses *** */ #include "resmall.h" Display *myDisplay; static XrmOptionDescRec options[] = { {"-label\0","*button.label\0",XrmoptionSepArg, NULL} }; Syntax(call) char *call; { fprintf(stderr,"Usage: %s\n",call); } void Quit(w,client_data,call_data) Widget w; caddr_t client_data, call_data; { exit(0); } void Clear(wid,client_data,call_data) Widget wid; caddr_t client_data, call_data; { sprintf(s1,""); XtTextSetLastPos(w1,0); } /*************** M A I N ***********************************/ void main(argc,argv) char **argv; { int i,j; char s[20]; toplevel = XtInitialize("main","Demo",NULL,0, &argc,argv); n = 0; XtSetArg(args[n], XtNx, 20); n++; XtSetArg(args[n], XtNy, 0); n++; XtSetArg(args[n], XtNwidth, 200); n++; XtSetArg(args[n], XtNheight, 200); n++; XtSetValues(toplevel, args, n); myDisplay = XtDisplay(toplevel); n = 0; XtSetArg(args[n], XtNx, 0); n++; XtSetArg(args[n], XtNy, 0); n++; XtSetArg(args[n], XtNborderWidth, 0); n++; Form1 = XtCreateManagedWidget("Form1",formWidgetClass,toplevel,args, n); n = 0; XtSetArg(args[n], XtNborderWidth, 1); n++; XtSetArg(args[n], XtNlength, 18); n++; XtSetArg(args[n], XtNeditType, XttextEdit); n++; XtSetArg(args[n], XtNtextOptions, editable | scrollHorizontal); n++; XtSetArg(args[n], XtNvertDistance, 20); n++; XtSetArg(args[n], XtNlength, 29); n++; XtSetArg(args[n], XtNwidth, 80); n++; XtSetArg(args[n], XtNhorizDistance, 10); n++; sprintf(s,"w1"); XtSetArg(args[n], XtNstring, s1); n++; w1 = XtCreateManagedWidget(s,asciiStringWidgetClass,Form1,args, n); /*XtTextEnableRedisplay(w1);*/ n = 0; XtSetArg(args[n], XtNhorizDistance, 10); n++; XtSetArg(args[n], XtNvertDistance, 60); n++; XtSetArg(args[n], XtNheight, 30); n++; XtSetArg(args[n], XtNwidth, 40); n++; XtSetArg(args[n], XtNborderWidth, 1); n++; XtSetArg(args[n], XtNresize, False); n++; XtSetArg(args[n], XtNcursor, XCreateFontCursor(myDisplay, XC_gumby)); n++; quitButton = XtCreateManagedWidget("Quit",commandWidgetClass,Form1,args, n); n = 0; XtSetArg(args[n], XtNhorizDistance, 60); n++; XtSetArg(args[n], XtNvertDistance, 60); n++; XtSetArg(args[n], XtNheight, 30); n++; XtSetArg(args[n], XtNwidth, 40); n++; XtSetArg(args[n], XtNborderWidth, 1); n++; XtSetArg(args[n], XtNresize, False); n++; XtSetArg(args[n], XtNcursor, XCreateFontCursor(myDisplay, XC_gumby)); n++; clearButton = XtCreateManagedWidget("Clear",commandWidgetClass,Form1,args, n); XtAddCallback(quitButton, XtNcallback, Quit, NULL); XtAddCallback(clearButton, XtNcallback, Clear, NULL); XtRealizeWidget(toplevel); XtMainLoop(); }