[comp.windows.x.motif] Function Keys on a Sparcstation

nazgul@alfalfa.com (Kee Hinckley) (06/12/91)

> 
> 
> 	Does anyone know how to get the Undo/Cut/Copy/Paste/... keys
> to work for a motif application on a SUN Sparcstation?  Also, my Alt
> key does not work either.

I'd be very interested in what you find out.  Alt works for me,
but only using the diamond button as alt.  But I've had customers
who say that it works for mnemonics, but not for accelerators, which
is pretty strange.

Alfalfa Software, Inc.          |       Poste:  The EMail for Unix
nazgul@alfalfa.com              |       Send Anything... Anywhere
617/646-7703 (voice/fax)        |       info@alfalfa.com

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

nichol@asc.slb.com (Bruce Nichol) (06/13/91)

	Does anyone know how to get the Undo/Cut/Copy/Paste/... keys
to work for a motif application on a SUN Sparcstation?  Also, my Alt
key does not work either.

	F10 does however, work as advertised.  But that is the only
one. 

	Any help would be appreciated.

nichol@asc.slb.com
-- 


			Bruce
				

jerryl@is.Morgan.COM (Jerry Liebelson) (06/14/91)

> 
> > 
> > 
> > 	Does anyone know how to get the Undo/Cut/Copy/Paste/... keys
> > to work for a motif application on a SUN Sparcstation?  Also, my Alt
> > key does not work either.
> 
> I'd be very interested in what you find out.  Alt works for me,
> but only using the diamond button as alt.  But I've had customers
> who say that it works for mnemonics, but not for accelerators, which
> is pretty strange.
> 

Getting the real Alt key to work is easily accomplished with xmodmap
in your .xinitrc file:

     xmodmap -e "add mod1 = Alt_L"

The following also gets rid of the annoying backspace/delete problem:
     xmodmap -e "keycode 73 = BackSpace"


As for the getting the Undo/Cut/Copy/Paste keys to work, check out the
program below. Remember that because the Sun keyboard has additional keys,
F11 and F12 are the same as 2 of the L keys. 

I still can't figure out how to get the following keys to trigger the callback:
in the program below:
         F1, F4, F10, Arrow Keys, Insert, Delete, BackSpace


-- 
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
|        Jerry Liebelson         |      EMAIL: jerryl@is.morgan.com          |
|      Information Systems       |             uunet!is.morgan.com!jerryl    |
|      Morgan Stanley, Inc.      |      VOICE: (212) 703-2409                |
|      1633 Broadway 36th Floor  |      FAX:   (212) 703-2371                |
|      New York, NY 10019        |                                           |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

----------------------------- cut here  -------------------------------------
 #include <stdio.h>
 #include <Intrinsic.h>
 #include <StringDefs.h>
 #include <keysym.h>
 #include <Xm/BulletinB.h>
 #include <Xm/PushB.h>
 
 void  ButtonCallback();
 
 Widget AppShell;
 static String Accelerators=
 {
   "#override \n\
             Shift<KeyPress>R15:  ArmAndActivate() \n\
              Shift<KeyPress>R9:  ArmAndActivate() \n\
              Shift<KeyPress>R7:  ArmAndActivate() \n\
                Shift<KeyPress>R13:  ArmAndActivate() \n\
                Shift<KeyPress>Tab:  ArmAndActivate() \n\
                Shift<KeyPress>F21:  ArmAndActivate() \n\
                Shift<KeyPress>F22:  ArmAndActivate() \n\
                Shift<KeyPress>F23:  ArmAndActivate() \n\
                Shift<KeyPress>F24:  ArmAndActivate() \n\
                Shift<KeyPress>F25:  ArmAndActivate() \n\
                Shift<KeyPress>F26:  ArmAndActivate() \n\
                Shift<KeyPress>F28:  ArmAndActivate() \n\
                Shift<KeyPress>F30:  ArmAndActivate() \n\
                Shift<KeyPress>F31:  ArmAndActivate() \n\
                Shift<KeyPress>F32:  ArmAndActivate() \n\
                Shift<KeyPress>F34:  ArmAndActivate() \n\
                Shift<KeyPress>Left:  ArmAndActivate() \n\
                Shift<KeyPress>Down:  ArmAndActivate() \n\
                Shift<KeyPress>Right:  ArmAndActivate() \n\
                Shift<KeyPress>Up:  ArmAndActivate() \n\
                Shift<KeyPress>Help:  ArmAndActivate() \n\
                Shift<KeyPress>KP_Add:  ArmAndActivate() \n\
                Shift<KeyPress>KP_Subtract:  ArmAndActivate() \n\
                Shift<KeyPress>KP_Enter:  ArmAndActivate() \n\
                Shift<KeyPress>Return:  ArmAndActivate() \n\
                Shift<KeyPress>Insert:  ArmAndActivate() \n\
                Shift<KeyPress>BackSpace:  ArmAndActivate() \n\
                Shift<KeyPress>Delete: ArmAndActivate() \n\
                Shift<KeyPress>Num_Lock: ArmAndActivate() \n\
              <KeyPress>R15:  ArmAndActivate() \n\
              <KeyPress>R9:  ArmAndActivate() \n\
              <KeyPress>R7:  ArmAndActivate() \n\
                <KeyPress>R13:  ArmAndActivate() \n\
                <KeyPress>Tab:  ArmAndActivate() \n\
                <KeyPress>F1:  ArmAndActivate() \n\
                <KeyPress>F2:  ArmAndActivate() \n\
                <KeyPress>F3:  ArmAndActivate() \n\
                <KeyPress>F4:  ArmAndActivate() \n\
                <KeyPress>F5:  ArmAndActivate() \n\
                <KeyPress>F6:  ArmAndActivate() \n\
                <KeyPress>F7:  ArmAndActivate() \n\
                <KeyPress>F8:  ArmAndActivate() \n\
                <KeyPress>F9:  ArmAndActivate() \n\
                <KeyPress>F10:  ArmAndActivate() \n\
                <KeyPress>F11:  ArmAndActivate() \n\
                <KeyPress>F12:  ArmAndActivate() \n\
                <KeyPress>F13:  ArmAndActivate() \n\
                <KeyPress>F14:  ArmAndActivate() \n\
                <KeyPress>F15:  ArmAndActivate() \n\
                <KeyPress>F16:  ArmAndActivate() \n\
                <KeyPress>F17:  ArmAndActivate() \n\
                <KeyPress>F18:  ArmAndActivate() \n\
                <KeyPress>F19:  ArmAndActivate() \n\
                <KeyPress>F20:  ArmAndActivate() \n\
                <KeyPress>F21:  ArmAndActivate() \n\
                <KeyPress>F22:  ArmAndActivate() \n\
                <KeyPress>F23:  ArmAndActivate() \n\
                <KeyPress>F24:  ArmAndActivate() \n\
                <KeyPress>F25:  ArmAndActivate() \n\
                <KeyPress>F26:  ArmAndActivate() \n\
                <KeyPress>F28:  ArmAndActivate() \n\
                <KeyPress>F30:  ArmAndActivate() \n\
                <KeyPress>F31:  ArmAndActivate() \n\
                <KeyPress>F32:  ArmAndActivate() \n\
                <KeyPress>F34:  ArmAndActivate() \n\
                <KeyPress>Left:  ArmAndActivate() \n\
                <KeyPress>Down:  ArmAndActivate() \n\
                <KeyPress>Right:  ArmAndActivate() \n\
                <KeyPress>Up:  ArmAndActivate() \n\
                <KeyPress>Help:  ArmAndActivate() \n\
                <KeyPress>KP_Add:  ArmAndActivate() \n\
                <KeyPress>KP_Subtract:  ArmAndActivate() \n\
                <KeyPress>KP_Enter:  ArmAndActivate() \n\
                <KeyPress>Return:  ArmAndActivate() \n\
                <KeyPress>Insert:  ArmAndActivate() \n\
                <KeyPress>BackSpace:  ArmAndActivate() \n\
                <KeyPress>Delete: ArmAndActivate() \n\
                <KeyPress>Num_Lock: ArmAndActivate()"
 };
 
 static Atom WmDeleteWindowAtom, WmProtocolsAtom;
 
 typedef struct
 {
   KeySym keySym;  
   char *keyName;
 } KEY;
 
 static KEY Keys[] =
 {
   XK_F1, "F1",     
   XK_F2, "F2",
   XK_F3, "F3",
   XK_F4, "F4",
   XK_F5, "F5",
   XK_F6, "F6",
   XK_F7, "F7",
   XK_F8, "F8",
   XK_F9, "F9",
   XK_F10, "F10",
   XK_F11, "F11",
   XK_F12, "F12",
   XK_F13, "L3",
   XK_F14, "L4",
   XK_F15, "L5",
   XK_F16, "L6",
   XK_F17, "L7",
   XK_F18, "L8",
   XK_F19, "L9",
   XK_F20, "L10",
   XK_F21, "Pause",
   XK_F22, "PrSc",
   XK_F23, "ScrollLock",
   XK_F24, "R4",
   XK_F25, "R5",
   XK_F26, "R6",
   XK_F31, "KP_5",
   XK_KP_Enter, "KP_Enter",
   XK_Return, "Return",
   XK_Help, "Help",
   XK_Insert, "Insert",
   XK_Delete, "Delete",
   XK_BackSpace, "BackSpace",
   XK_Right, "Right",
   XK_Left, "Left",
   XK_Up, "Up",
   XK_Down, "Down",
   XK_R7, "Home",
   XK_R13, "End",
   XK_R9, "PgUp",
   XK_R15, "PgDn",
   XK_Tab, "TAB",
   XK_KP_Add, "KP_Add",
   XK_KP_Subtract, "KP_Subtract",
   XK_Num_Lock, "NumLock"
 };
 
 static int NumKeys = sizeof(Keys)/sizeof(Keys[0]);
 /***************************************************************************/
 int main(argc, argv)
 int argc;
 char **argv;
 {
 
   Widget board, button;
   Arg argList[10];
   int i;
   XtAppContext appContext;
   Display *displayPtr;
   char appClass[64];
   
 
   strcpy(appClass,argv[0]);
 
     if (islower(appClass[0]))
     appClass[0] = toupper(appClass[0]);
     else if (islower(appClass[1]))
         appClass[1] = toupper(appClass[1]);
     
   AppShell = XtAppInitialize ( 
     &appContext, appClass, NULL, 0,
     &argc, argv,
     NULL, NULL, 0    
     );
 
   board = XtCreateManagedWidget("board", xmBulletinBoardWidgetClass, AppShell,
     NULL, 0);
 
   XmRemoveTabGroup(board);
 
   i=0;
   XtSetArg (argList[i], XmNaccelerators,
      XtParseAcceleratorTable(Accelerators)); i++;
   button = XtCreateManagedWidget("button", xmPushButtonWidgetClass, board,
     argList, i);
 
   XtAddCallback(button, XmNactivateCallback, ButtonCallback, NULL);
 
 
   XtRealizeWidget(AppShell);
 
   XtInstallAllAccelerators(button, board);
 
   XtAppMainLoop(appContext);
 
   exit(-1);
 }
 
 void ButtonCallback(widget, clientData, callData)
   Widget widget;
   caddr_t clientData;
   XmAnyCallbackStruct *callData;
 {
   char keyString[12];
   KeySym keySym;
   register int i;
 
   XLookupString(&callData->event->xkey,
      keyString, sizeof(keyString), &keySym, NULL);
   
   if (callData->event->xkey.state & ShiftMask)
       fprintf(stderr, "Shift ");
 
   for (i = 0; i < NumKeys; i++)
   {
     if (keySym == Keys[i].keySym )    
          fprintf(stderr, Keys[i].keyName);
   }
   fprintf(stderr, " Pressed\n");
 }
 
 ---------------------------- cut here  -------------------------------------