bill@entropy.ms.washington.edu (Bill Dunlap) (09/23/88)
I have written a widget which allows the user to choose one of a fixed number of choices and displays the current choice. One resource is its "state", the index number of the current choice. Another is a callback list to be called whenever the state is changed. The most convenient place to call the callbacks is in SetValues() : static void SetValues(current, request, new) Widget current, request, new ; { ChoiceWidget c = (ChoiceWidget)current ; ChoiceWidget n = (ChoiceWidget)new ; ... if (c->choice.state != n->choice.state) { if (n->choice.state < 0) n->choice.state = 0 ; n->choice.state %= n->choice.nstates ; XtCallCallbacks(n, XtNcallbacks, (caddr_t)n->choice.state) ; } ... } Now the callback routines are called, but the widget handed to them is "current", not "new" so the callback cannot use XtGetValues to get the most up to date information on the widget. This is because the callback list in new is a verbatim copy of that in current and includes a pointer to its master and the pointer does not get updated in the copy. Should I not call callbacks from SetValues? That would clutter the code significantly. (It would force the program setting the state of the widget to call the appropriate callbacks.) Should I not call XtGetValues from callbacks? I can get away with that in this case but seems like an artificial restriction. Should XtSetvalues in Xt/Resources.c be changed so that a copy widget procedure does a "proper" copy instead of just using bcopy to copy the bytes? Bill Dunlap (bill@elk.ms.washington.edu) Dept of Statistics, University of Washington