[comp.windows.x.motif] Button clicks in motif

victor@devorah.tcs.com (Victor Elkind) (01/24/91)

I want to invoke different methods in my application based on various
button clicks on a motif widget, ie shift-Click1, doubleClick1, click2,
shift-Click2, etc.  I can see only two ways to do this.

1) Change the widget's translation table to call the activateCallback for
all the click combinations that I am interested in, and then check the XEvent
structure passed in the activateCallback routine for which buttons were
pressed to cause this callback and call the appropriate method in my
application.

2) Add new callbacks (reasons) to a widget and specify which key/button
combinations cause this callback to be invoked.  Can this be done without
creating a widget subclass?

I am using Motif 1.0 and UIL.  Can anybody suggest a better way to do what
I want or which way is easier (1 or 2)?

I tried the approach #1 by changing XmNtranslations for a DrawnButton
widget in UIL, however, when I ran the sample program, the button
only responded to clicks of Btn 1 but not to clicks of Btn 2.

Here is a fragment of my uil file.

object Symbol : XmDrawnButton widget {
    arguments {
        XmNbackgroundPixmap = xbitmapfile(sym_bm);
        XmNrecomputeSize = false;
        XmNtraversalOn = false;
        XmNlabelString = '';
        XmNx = 5;
        XmNy = 5;
        XmNwidth = 50;
        XmNheight = 50;
        XmNpushButtonEnabled = true;
        XmNtranslations = translation_table(
                        '#replace',
                        '<Btn2Down>:            Arm()',
                        '<Btn2Down>,<Btn2Up>:   Activate() Disarm()',
                        '<Btn2Down>,<Btn2Up>:   Activate() Disarm()',
                        '<Btn2Down>(2+):        Arm()',
                        '<Btn2Up>(2+):          Activate()',
                        '<Btn2Up>:              Activate() Disarm()',
                        '<Btn1Down>:            Arm()',
                        '<Btn1Down>,<Btn1Up>:   Activate() Disarm()',
                        '<Btn1Down>,<Btn1Up>:   Activate() Disarm()',
                        '<Btn1Down>(2+):        Arm()',
                        '<Btn1Up>(2+):          Activate()',
                        '<Btn1Up>:              Activate() Disarm()'
                        );
    };

Does anyone have any suggestions on why this does not work?

Please, email your replies to victor@tcs.com.

Many thanks in advance.

Victor