y2@DINORAH.WUSTL.EDU (Yeong-Yeong Liu) (12/03/88)
Three days ago I posted a mail titled "R3 and R2 translation table compatible?" and I didn't get any response. While waiting, I tried several things and thought I'll post the old mail again with what I have done so somebody may steer me to the right direction. ========== here is "R3 and R2 translation table compatible?"========= I had an application written with X11.2. It has multiple command widgets and their common grandparent is a form widget named "mainwidget". I needed the flexibility of activating any of the commands by either striking a unique key on keyboard or by focusing and clicking the mouse. The way I did it was by binding a set of keys (one key for each command, user selectable) to "mainwidget". Whenever the mouse is inside mainwidget, striking the appropriate key will activate the command. Everything was fine with release 2. Without any source change, the application broke after I recompiled it with R3. Running under dbx, the translation string bound to "mainwidget" looked like this: "<Key>R :set(353028) rfunc() unset(353028) \n <Key>I :set(357380) ifunc(RPEN1) unset(357380) \n <Key>T :set(357636) tfunc(RDCENTR0) unset(357636) \n <Key>P :set(357892) pfunc(RPMA1) unset(357892) \n <Key>S :set(358148) sfunc(RSMA1) unset(358148) \n <Key>U :set(358404) utility(RUTL1) unset(358404) \n <Key>B :set(358660) batch(RPQMM) unset(358660) \n <Key>Q :set(358916) quit() unset(358916) " I used XtAddActions(actionsTable,actionsTableCount); XtOverrideTranslations(keyparent, XtParseTranslationTable(transtring)); where actionsTable sets {"quit", Quit}, {"set", Set}, {"unset", Unset}, etc. keyparent is "mainwidget", while transtring is tranlation string above. My problem is that my callback Set function was never dispatched (I set stop at first executable line in subroutine Set and the program never stopped after a key struck). Any idea what's wrong? Where or how to look? Is R3 getting sick from my translation table so that it does not dispatch when it should? Suggestions appreciated. Thanks. ============= end of "R3 and R2 translation table compatible?"========= In two different ways I continued my struggle: 1. Continue same program. Various tests tell me XtOverrideTranlations worked if there is no XtAddActions call. I think the problem is the actionsTable is not registered with translation manager properly. What puzzled me is if the translation manager can not find "action names to procedure translations" in its own class, its superclass and the action tables registered with XtAddActions, then an error should be generated (Intrinsic manual chapt 10.1.2). Why is my key stroke simply ignored? Has anybody used XtAddActions and XtOverridTranslations calls with X11.3? 2. Modified program to use display_accelerator. I did the following steps and it worked. BUT I had a minor problem which was resolved. . . /* create grandparent of command widgets */ mainwidget = XtCreateManagedWidget(...,formWidgetClass,...); /* create parent of command widgets */ panel = XtCreateManagedWidget(..,formWidgetClass,...); /* start of command widgets creation loop */ . /* setup string which look like: "<KeyDown>x:highlight() set()\n <KeyUp>:notify() unset() reset()" */ . XtSetArg(args[n],XtNaccelerators,XtParseAcceleratorTable(string)); . button = XtCreateManagedWidget(..,commandWidgetClass,..); . XtOverrideTranslations(button, XtParseTranslationTable(trans)); . /* end of command widget loop */ XtInstallAllAccelerators(mainwidget,panel); . . Suppose I have 3 command widgets, the program loop above creates 3 widgets with key a,b and c bound to command 1,2,3 respectively. XtInstallAllAccelerators() installs these binding to mainwidget. So I can activate any of the commands by striking their binding key. It all worked except that when my pointer happened to be inside one of the command widgets, then the keys bound to the other two widgets will not work. Since the other keys are not in the current command widget's translation table, I thought the key event should be passed to its parent (panel widget) which in turn passed it to mainwidget which acted on it. Am I wrong? A wild guess made me recompile the program by removing the XtOverrideTranslations() call and it worked. I guess there must be a good reason behind this, but it was not explained in the manual. Yeong Yeong Liu {uunet...}!wucs1!dinorah!y2 or wucs1.wustl.edu!dinorah!y2 or y2@dinorah.wustl.edu or 314-362-2950