devil@diablery.10A.com (Gil Tene) (05/16/91)
Hello X'ers,
I was trying to specify a callback funtions for a Xaw AsciiText,
and found this "strange" behaviour :
When trying to specify the callback using :
XtAddCallback(text1, XtNcallback,
MyTextCBhandler, (XtPointer) &text_data1);
I get a "Warning: Cannot find callback list in XtAddCallbacks"
at runtime, and the callback doesn't work...
BUT: when I specify an explicit callback list during the creation
of the asciiTextWidget, it works... (took me a while to think of
trying it this way) :
static XtCallbackRec text_callback_list[] = {
{MyTextCBhandler, (XtPointer) NULL},
{(XtCallbackProc) NULL, (caddr_t) NULL}
};
.
.
.
XtSetArg(args[0], XtNstring,
"This is a test...");
text_callback_list[0].closure = (XtPointer) &text_data1;
XtSetArg(args[1], XtNcallback, text_callback_list);
text1 = XtCreateManagedWidget("text1", asciiTextWidgetClass, paned,
args, 2);
Any idea why this is? It would seem much easier and much more "elegant"
to use the usual XtAddCallback call...
AdvThanks,
-- Gil.
--
--------------------------------------------------------------------
-- Gil Tene "Some days it just dosn't pay -
-- devil%imp@uunet.uu.net to go to sleep in the morning." -
-- devil@diablery.10A.com -
--------------------------------------------------------------------
de@aspen30.cray.com (Duane Eitzen) (05/18/91)
In article <341@imp.UUCP> devil@diablery.10A.com (Gil Tene) writes: >Hello X'ers, > >I was trying to specify a callback funtions for a Xaw AsciiText, >and found this "strange" behaviour : > >When trying to specify the callback using : > XtAddCallback(text1, XtNcallback, > MyTextCBhandler, (XtPointer) &text_data1); > >I get a "Warning: Cannot find callback list in XtAddCallbacks" >at runtime, and the callback doesn't work... > >BUT: when I specify an explicit callback list during the creation >of the asciiTextWidget, it works... (took me a while to think of >trying it this way) : > I am just learning X myself and I hit the same problem. The source of the problem is that the "callback" resource is actually a resource of the "AsciiSrc". Thus you can go: XtAddCallback(XawTextGetSource(tgadget),XtNcallback, ...) Duane Eitzen.