converse@EXPO.LCS.MIT.EDU (Donna Converse) (05/30/90)
> My task is to bind the event of a return key in several widgets > to the action of pressing a button in a command widget. > This was no problem using Accelerators. I also have a list > widget that I would like to have a double-click cause the same action > to take place. Now I am confussed. I want only the double-click > in the list widget to cause this action (not double-clicks anywhere). Accelerators allow you to bind events in one widget to actions in another. In this case you would like to bind double click events in the List widget to an action in the Command widget. In the language used in the Xt Intrinsics manual, the Command widget is the source widget and the List is the destination widget. You would write something like commandButtonName.accelerators: #override\n\ <BtnUp>(2) : set()notify()unset() And then in code, install the accelerators of the Command widget upon the List widget: XtInstallAccelerators(listWidgetID, commandWidgetID) Then only in the List widget, a double button click will cause the named action procedures to be invoked, and the first parameter will be the widgetID of the command widget. You already understood all this when you did the Return key accelerators, I would bet. Now in your particular example, there are two complications: 1) The Command widget in your program has another value already given in its accelerator resource, which you want to be installed elsewhere -- the Return accelerator. Compile the accelerator table for the Return key, set the accelerator resource of the Command widget, install the accelerator wherever, as you do currently. Then, reset the accelerator resource of the Command widget to the compiled accelerator table for the double click event, and then install the accelerator as above. I'm reading in between the lines of the Xt spec, and it seems to me that you do not have to preserve the value of the Command widget's accelerator resource once it has been installed on the appropriate widgets. Try it and see if it works. 2) The Athena List widget already has a translation for a single button click. Double clicking will cause both the List widget action and your accelerator action to be taken. If this is a problem, consider making the accelerator be a modified click such as control-click (i.e. pressing down the control key while clicking the mouse button.) > What I previously have is double-clicks anywhere cause the action > to fire off. I think this is due to using an inappropriate destination widget ID, and also due to installing the accelerators on the destination widget's descendants. Separating the installation of the Return key accelerator from the installation of the double click accelerator should relieve this problem. > So I was wondering if someone would like to step forward and explain > Accelerators to me in English. Yes I have read the DOCUMENTATION > and it just isn't sinking in. Or just point me to an example > and I will try that route. Describing the steps needed in setting > up the previous paragraph would be great. Agh. Maybe I could write a poem about accelerators. :-) Seriously, there's more than one book out there, and more on the way to the presses, that you could read. I know the spec reads like a math text. Donna Converse converse@expo.lcs.mit.edu