Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!bloom-beacon!SEI.CMU.EDU!Rick.Kazman From: Rick.Kazman@SEI.CMU.EDU Newsgroups: comp.windows.x Subject: text widget bug? Message-ID: <8906121752.AA22596@ew.sei.cmu.edu> Date: 12 Jun 89 17:52:28 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 89 A while ago, I posted, asking information about text strings in the Athena text widgets, and I was told that they are just like ordinary strings in C: they terminate with a '\0' character. I was also told that the text widget uses strlen() to determine the length of the string. However, it appears to me that once the text widget thinks it knows the length of the string that you're displaying, it doesn't check the string again to determine its length. I have enclosed a test program which demonstrates this. This program has a command widget and a text widget, enclosed in a form widget. When the user presses the command button, he gets prompted to enter the text to be displayed in the text widget. When the text is redisplayed, only the number of characters in the original text are displayed--larger strings get truncated and shorter ones have the end of the old string tacked onto them. So, my question is, how do I get the text widget to look at the string again, to determine its new length? Thanks. rick p.s. I'm running a Sun 3/60 with X11/R3 and the Athena widget set. ______________________________________________________________________ #include #include #include #include #include #include #include #include char temp_body[100] = "bungfig" ; XtCallbackProc Activate(w, client_data, call_data) Widget w; caddr_t client_data ; caddr_t call_data ; { printf("Gimme one: "); scanf("%s", temp_body) ; } void main(argc, argv) unsigned int argc; char **argv; { int n ; Widget toplevel, command_widget1, form_widget, text_widget1 ; Arg args[25] ; static XtCallbackRec callbacks[] = { { Activate, (caddr_t) NULL }, { NULL, NULL }, }; toplevel = XtInitialize ("test1", "Test1", NULL, 0, &argc, argv); form_widget = XtCreateManagedWidget( "form", formWidgetClass, toplevel, args, XtNumber(args) ); n = 0 ; XtSetArg(args[n], XtNhorizDistance, (XtArgVal) 150) ; n++; XtSetArg(args[n], XtNvertDistance, (XtArgVal) 175) ; n++; XtSetArg(args[n], XtNwidth, (XtArgVal) 200) ; n++; XtSetArg(args[n], XtNheight, (XtArgVal) 50) ; n++; XtSetArg(args[n], XtNeditType, (XtArgVal) XttextEdit) ; n++; XtSetArg(args[n], XtNtextOptions, (XtArgVal) editable) ; n++; XtSetArg(args[n], XtNlength, (XtArgVal) 100) ; n++; XtSetArg(args[n], XtNstring, temp_body); text_widget1 = XtCreateManagedWidget("", asciiStringWidgetClass, form_widget, args, XtNumber(args) ); n = 0 ; XtSetArg(args[n], XtNcallback, (XtArgVal) callbacks) ; n++; XtSetArg(args[n], XtNlabel, "Scudda hoo") ; n++; XtSetArg(args[n], XtNhorizDistance, (XtArgVal) 10) ; n++; XtSetArg(args[n], XtNvertDistance, (XtArgVal) 10) ; n++; XtSetArg(args[n], XtNwidth, (XtArgVal) 100) ; n++; XtSetArg(args[n], XtNheight, (XtArgVal) 50) ; n++; command_widget1 = XtCreateManagedWidget( "command", commandWidgetClass, form_widget, args, XtNumber(args) ); XtRealizeWidget(toplevel); XtMainLoop() ; }