home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / windows / x / 18966 < prev    next >
Encoding:
Internet Message Format  |  1992-11-12  |  2.3 KB

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