morreale@ncar.ucar.edu (Peter Morreale) (12/05/90)
I'm having what is probably a simple problem with the Xt toggle widget. ( X11R4, patched to fix-18, SunOS...) ( Chris D. Peterson where are you?????? ;-) I have three toggles and only want a single toggle to be set at any given point in time (a radioGroup). This is easy enough, and I coded this action with no problems for pointer buttons. Here's the problem.... What I want is an action such that when the user hits a control key, I reset one of toggles in the radioGroup. In other words, to the user, a Ctrl-W should perform the exact same action as a button click in the Type_Walkin toggle widget. The action function is working correctly except that I can't seem to change the state of the toggles in the radioGroup. I am trying to use XawToggleSetCurrent and am obviously using it incorrectly (or I have the initial resources for the toggle group set incorrectly...) I have verifed that I *am* reaching the correct portion of my action function, however I am unable to change the state of the toggle implied by the keypress in the action function. Can someone please look at the following code and tell me what I need to do? I've been through *many* iterations of changes, but I can't seem to hit upon the correct combination..... CREATION OF THE TOGGLES.... ----------------start of code sample----------------------------------- ......... String TransTable2 = "<EnterWindow>: highlight(Always)\n\ <LeaveWindow>: unhighlight() \n\ <Btn1Down>,<Btn1Up>: set() notify()"; ......... /* First three toggles to tell what kind of contact * Note the overriding of previous "arg" data..... */ RadioTrans2 = XtParseTranslationTable(TransTable2); n = 0; XtSetArg(arg[n], XtNhorizDistance, 15); ++n; XtSetArg(arg[n], XtNtranslations, RadioTrans2); ++n; XtSetArg(arg[n], XtNstate, True); ++n; XtSetArg(arg[n], XtNradioData, "phone"); ++n; Type_Phone = XtCreateManagedWidget("phone", toggleWidgetClass, Contacts, arg, n); XtAddCallback(Type_Phone, XtNcallback, Types, 'P'); XtSetArg(arg[2], XtNradioGroup, Type_Phone); /* Add to the group */ XtSetArg(arg[3], XtNradioData, "mail"); /* add data */ Type_Mail = XtCreateManagedWidget("mail", toggleWidgetClass, Contacts, arg, n); XtAddCallback(Type_Mail, XtNcallback, Types, 'M'); XtSetArg(arg[2], XtNradioGroup, Type_Mail); /* Add to the group */ XtSetArg(arg[3], XtNradioData, "walkin"); /* add data */ Type_Walkin = XtCreateManagedWidget("walkin", toggleWidgetClass, Contacts, arg, n); XtAddCallback(Type_Walkin, XtNcallback, Types, 'W'); ---------end of code sample-------------------------------------- GENERIC ACTION FUNCTION INVOKED WITH Ctrl-? ----------------start of code sample----------------------------------- void Key_Stuff(widget, event, params, num_params) Widget widget; XEvent *event; String *params; Cardinal *num_params; { void XawToggleSetCurrent(); switch (params[0][0]) { case 'f': { Fill(widget, NULL, NULL); break; } case 's': { Save(widget, NULL, NULL); break; } case 'q': { Quit(widget, NULL, NULL); break; } case 'd': { Done(widget, NULL, NULL); break; } case 'r': { Report(widget, NULL, NULL); break; } case 'p': /* change the current toggle */ { printf("case phone reached\n"); XawToggleSetCurrent(Type_Mail, "phone"); break; } case 'm': /* change the current toggle */ { printf("case mail reached\n"); XawToggleSetCurrent(Type_Mail, "mail"); break; } case 'w': /* change the current toggle */ { printf("case walkin reached\n"); XawToggleSetCurrent(Type_Mail, "walkin"); break; } } } /* END KEY_STUFF */ Thanks much... -PWM ------------------------------------------------------------------ Peter W. Morreale email: morreale@ncar.ucar.edu Nat'l Center for Atmos Research voice: (303) 497-1293 Scientific Computing Division Consulting Office ------------------------------------------------------------------
converse@EXPO.LCS.MIT.EDU (12/06/90)
> I'm having what is probably a simple problem with the Xt toggle > widget. ( X11R4, patched to fix-18, SunOS...) > > ( Chris D. Peterson where are you?????? ;-) The collective wisdom of the net will have to supply the leadership to guide new X programmers. There is an enormous demand for my time, and Chris is very probably in a similar position. Now there are many programmers who could step in and answer questions; I encourage them to post answers. > The action function is working correctly except > that I can't seem to change the state of the toggles in the radioGroup. > I am trying to use XawToggleSetCurrent and am obviously using it incorrectly > (or I have the initial resources for the toggle group set incorrectly...) Good, right on the mark. When you create the Athena Toggle widget, you supply some radio data: > XtSetArg(arg[n], XtNradioData, "phone"); ++n; > > Type_Phone = XtCreateManagedWidget("phone", toggleWidgetClass, When you call this function, you are specifying different radio data: > XawToggleSetCurrent(Type_Mail, "phone"); The value of the radio data resource is a pointer. These two "phone" strings have different addresses. If the radio data doesn't match, this function has no effect. Donna Converse Research Staff