Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!tcs.com!jordan From: jordan@tcs.com (Jordan Hayes) Newsgroups: comp.windows.x.motif Subject: weird behavior with ScrolledList Message-ID: <9105131738.AA03313@dwight.tcs.com> Date: 13 May 91 17:38:30 GMT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 105 1.1.1, SunOs 4.1.1, MIT/18, etc. In the example below, I create an applicationShell, and put an XmButton in it. When the button is pushed, XtAppWarning is called. Also, I create a topLevelShell with an XmScrolledList in it. Then I install a warning handler, which takes the string and makes an entry in the list. Here's what happens when I run it: the first time I push the button, the message appears. Subsequent times I push the button, nothing shows up (the list area doesn't get redrawn). When there are enough lines such that it would scroll, the list gets redrawn (when the scrollbars show up). Before the scrollbars show up, if I resize the window, the messages appear, and it begins to work correctly. Any guesses? Code follows ... ===== #include #include #include #include static Widget _ErrList; static XtAppContext app; static void ErrBoxWarnFunc(s) char *s; { char *cp, *cp1; XmString str; if (s == NULL || *s == NULL) return; for (cp = s; *cp != NULL; cp = cp1) { for (cp1 = cp; *cp1 != NULL && *cp1 != '\n'; cp1++) ; if (*cp1 == '\n') *cp1++ = NULL; str = XmStringCreateLtoR(s, XmSTRING_DEFAULT_CHARSET); XmListAddItem(_ErrList, str, 0); XmStringFree(str); } } static void _AddMore(w, client, call) Widget w; XtPointer client; XtPointer call; { char buf[BUFSIZ]; static int i; (void)sprintf(buf, "Push number %d\n", i++); XtAppWarning(app, buf); } main(argc, argv) int argc; char **argv; { Display *display; Widget shell, button, errBox; /* setup */ XtToolkitInitialize(); app = XtCreateApplicationContext(); if ((display = XtOpenDisplay(app, NULL, NULL, "Testing", NULL, 0, (Cardinal *)&argc, argv)) == (Display *)NULL) { fprintf(stderr, "Cannot open display \"%s\"\n", XDisplayName(NULL)); exit(-1); } /* make a shell with a button */ shell = XtAppCreateShell(NULL, NULL, applicationShellWidgetClass, display, NULL, 0); button = XmCreatePushButton(shell, "PushMe", NULL, 0); XtAddCallback(button, XmNactivateCallback, _AddMore, NULL); XtManageChild(button); XtRealizeWidget(shell); /* make the error window */ errBox = XtAppCreateShell("ErrBox", NULL, topLevelShellWidgetClass, display, NULL, 0); _ErrList = XmCreateScrolledList(errBox, "errList", NULL, 0); XtManageChild(_ErrList); XtRealizeWidget(errBox); /* set the warning handler */ XtAppSetWarningHandler(app, ErrBoxWarnFunc); XtAppMainLoop(app); } ===== /jordan