🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.x
Article #37358

Xt Accelerators

#37358
From: John.Hagerman at.rx7
Date: Sun, 25 Feb 1990 19:27
56 lines
2075 bytes
I'm having trouble getting accelerators to work.  What's wrong with
the following code?  The intent is to have a Return keypress in the
dialog's `value' widget cause a set()notify()unset() action sequence
in the dialog's `show' widget.  I'm using the R3 Athena widgets on a
DS 3100 running Ultrix.

Thanks for any help - John
hagerman@ece.cmu.edu

#include <stdio.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Command.h>
#include <X11/Dialog.h>
#include <X11/Shell.h>

Widget Dialog;
Arg DialogArgs[] = {
    { XtNlabel, (XtArgVal) "label"},
    { XtNvalue, (XtArgVal) "value"},
};

ShowCallback(w, client_data, call_data)
    Widget w;
    caddr_t client_data, call_data;
{
    printf("%s\n", XtDialogGetValueString(Dialog));
}

main(argc, argv)
    int argc;
    char **argv;
{
    Display *dsp;
    XtAppContext ac;
    Widget top, cmd, val;
    XtAccelerators acc;
    Arg arg[1];

    XtToolkitInitialize();
    ac = XtCreateApplicationContext();
    dsp = XtOpenDisplay(ac, 0, 0, "accel", 0, 0, &argc, argv);
    top = XtAppCreateShell(0, "top", applicationShellWidgetClass, dsp, 0, 0);
    Dialog = XtCreateManagedWidget("dialog", dialogWidgetClass, top,
				   DialogArgs, XtNumber(DialogArgs));
    cmd = XtCreateManagedWidget("show", commandWidgetClass, Dialog, 0, 0);
    XtAddCallback(cmd, XtNcallback, ShowCallback, 0);
    val = XtNameToWidget(Dialog, "value");
    acc = XtParseAcceleratorTable("<Key>Return:set()notify()unset()");
    XtSetArg(arg[0], XtNaccelerators, (XtArgVal) acc);
    XtSetValues(cmd, arg, 1);
    XtInstallAccelerators(val, cmd);
    XtRealizeWidget(top);
    XtAppMainLoop(ac);
}
Technical Details
Message-ID: <9002251927.AA13834@rx7.ece.cmu.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!snorkelwacker!bloom-beacon!daemon

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!snorkelwacker!bloom-beacon!daemon
From: John.Hagerman@rx7.ece.cmu.EDU, at.rx7@rx7.ece.cmu.EDU
Newsgroups: comp.windows.x
Subject: Xt Accelerators
Message-ID: <9002251927.AA13834@rx7.ece.cmu.edu>
Date: 25 Feb 90 19:27:03 GMT
Sender: daemon@athena.mit.edu (Mr Background)
Organization: The Internet
Lines: 56