home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / fj / maillis / xwindow / 17552 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  2.5 KB

  1. Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!spool.mu.edu!sgiblab!nec-gw!nec-tyo!wnoc-tyo-news!scslwide!wsgw!wsservra!daemon
  2. From: rchui@nswc-wo.nswc.navy.mil (Raymond Chui)
  3. Newsgroups: fj.mail-lists.x-window
  4. Subject: Why KeyPress/Release not work in DrawingAreaWidget?
  5. Message-ID: <1992Nov17.140518.22322@sm.sony.co.jp>
  6. Date: 17 Nov 92 14:05:18 GMT
  7. Sender: daemon@sm.sony.co.jp (The devil himself)
  8. Distribution: fj
  9. Organization: Naval Surface Warfare Center - White Oak
  10. Lines: 79
  11. Approved: michael@sm.sony.co.jp
  12.  
  13. Date: 10 Nov 92 16:31:48 GMT
  14. Message-Id: <1992Nov10.163148.19985@relay.nswc.navy.mil>
  15. Newsgroups: comp.windows.x,comp.windows.x.motif,comp.windows.x.apps
  16. Sender: xpert-request@expo.lcs.mit.edu
  17.  
  18.  
  19. I am writing a Motif program, I try do some sample as following:
  20.  
  21. ....
  22. ....
  23. drawing_a = XtVaCreateManagedWidget("drawing_a",
  24.         xmDrawingAreaWidgetClass, sw, /* scroll widget */
  25.     ....
  26.     ....
  27.     NULL);
  28. XtAddCallback(drawing_a, XmNinputCallback, input, NULL);
  29. ......
  30. ......
  31.  
  32. void input(widget, data, cbs)
  33. Widget widget;
  34. XtPointer data;
  35. XmDrawingAreaCallbackStruct *cbs;
  36. {
  37.     XEvent *event = cbs->event;
  38.     .....;
  39.     .....;
  40.  
  41.     if (cbs->reason == XmCR_INPUT) {
  42.         switch (event->xany.type) {
  43.         case ButtonPress:
  44.             printf("got a buttonpress\n");
  45.             break;
  46.         case ButtonRelease:
  47.             printf("got a buttonrelease\n");
  48.             break;
  49.         case KeyPress:
  50.             printf("got a keypress event\n");
  51.             break;
  52.         case  KeyRelease:
  53.             printf("got a keyrelease event\n");
  54.             break;
  55.         default:
  56.             ;
  57.             break;
  58.         } /* end switch */
  59.     } /* end if */
  60. } /* end function */
  61.  
  62. This only work for ButtonPress/Release, but not KeyPress/Release, why?
  63.  
  64. If you see O'Reilly volume 6 "Motif Programming Manual" page 339
  65. Table 10-1 "Callback Reasons and Event Types"
  66. You will see:
  67.  
  68. Callback        cbs->event->xany.type        cbs->reason
  69. -------------------------------------------------------------------
  70. XmNinputCallback    ButtonPress, ButtonRelease,    XmCR_INPUT
  71.             KeyPress, KeyRelease
  72.  
  73. Can someone out there explain to me why the KeyPress/Release are
  74. not work for me? Do I missing something? Why the ButtonPress/Release
  75. are work for me?
  76. Thank you in advance!
  77.  
  78. -- 
  79. Raymond H. Chui
  80. NSWC N62
  81. 10901 New Hampshire Ave.
  82. Silver Spring, MD 20903-5000
  83. U.S.A.
  84. Voice:1-301-394-5192 Fax:1-301-394-5835
  85. E-Mail:rchui@nswc-wo.nswc.navy.mil
  86.  _ __                                  _    ,    __
  87. ' )  )                           /    ' )  /    /  ) /
  88.  /--' __. , , ____   ______   __/      /--/    /    /_  . . o
  89. /  \_(_(_(_/_/) ) )_(_) /) )_(_(_     /  ( o  (__/ / /_(_/_(_
  90.           /
  91.          '
  92.