Path: utzoo!attcan!uunet!lll-winken!ames!pasteur!ucbvax!bloom-beacon!ATHENA.MIT.EDU!swick From: swick@ATHENA.MIT.EDU (Ralph R. Swick) Newsgroups: comp.windows.x Subject: Re: How do accelerators work? Message-ID: <8901261304.AA19591@LYRE.MIT.EDU> Date: 26 Jan 89 13:04:41 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: DEC/MIT Project Athena Lines: 38 > Can anyone give me a real example of how to use one in real life, Apply the modification (patch) at the end of this message to x11r3/examples/Xaw/xboxes.c and add the following resource to your favorite resource file: Demo*quit.accelerators: Ctrlc: set() notify() then notice that ^C anywhere in the top-level window activates the 'quit' button. *** /u1/X/src/examples/Xaw/xboxes.c --- f.c *************** *** 54,59 **** --- 54,60 ---- char **argv; { Widget viewport, box, box1, box2, box3; + Widget q; static XtCallbackRec callbackList[] = { {callback, NULL}, {NULL, NULL} }; static Arg viewArgs[] = { {XtNallowVert, True}, {XtNallowHoriz, True} }; *************** *** 94,103 **** --- 95,106 ---- XtCreateManagedWidget("label2", labelWidgetClass, box2, NULL, ZERO); XtCreateManagedWidget("label3", labelWidgetClass, box3, NULL, ZERO); + q = XtCreateManagedWidget("quit", commandWidgetClass, box1, arg, ONE); XtCreateManagedWidget("command2", commandWidgetClass, box2, NULL, ZERO); XtCreateManagedWidget("command3", commandWidgetClass, box3, NULL, ZERO); + XtInstallAccelerators(toplevel, q); XtRealizeWidget(toplevel); XtMainLoop(); }