home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / windows / x / apps / 1001 < prev    next >
Encoding:
Internet Message Format  |  1992-09-11  |  1.9 KB

  1. Path: sparky!uunet!news.centerline.com!noc.near.net!bigboote.WPI.EDU!omar.WPI.EDU!kimshi
  2. From: kimshi@omar.WPI.EDU (Erik H Currin)
  3. Newsgroups: comp.windows.x.apps
  4. Subject: Re: REQUEST: some way of recording Xevents
  5. Date: 11 Sep 1992 14:59:04 GMT
  6. Organization: Worcester Polytechnic Institute
  7. Lines: 48
  8. Message-ID: <18qc7oINN90q@bigboote.WPI.EDU>
  9. References: <1992Sep10.151200.28214@bmerh85.bnr.ca> <16910@ucdavis.ucdavis.edu>
  10. NNTP-Posting-Host: omar.wpi.edu
  11. Summary: Use XtAddEventHandler
  12.  
  13. Ok, I thought of something that _might_ work.
  14.  
  15. First, if you have access to an X manual, look up XtAddEventHandler()
  16. to get better understanding of what exactly the procedure does.  The
  17. file /usr/include/X11/X.h has a list of events with their masks, you
  18. might want to look their also.
  19.  
  20. So, within your program, try the following:
  21.  
  22.     XtAddEventHandler(widget, eventmask, nonmaskable, handler, 
  23.               client_data); 
  24.     Widget widget;  /* The widget you use to record events */
  25.     XtEventMask event_mask; /* If want all of them, set to NoEventMask */
  26.     Boolean nonmaskable; /* Set to TRUE if want application to receive
  27.                                 event(s) nonconditionally */
  28.     XtEventHandler handler;  /* The procedure name to call on event */
  29.     caddr_t client_data; /* Data that might want to pass to handler */
  30.  
  31. For example:
  32.  
  33.     XtAddEventHandler(w, ButtonPressMask, FALSE, button, my_data);
  34.  
  35. will call the procedure button on a button press event.
  36. The button procedure takes the following parameters:
  37.  
  38.     void button(w, client_data, event)
  39.     Widget w;  /* The widget above in XtAddEventHandler */
  40.     caddr_t client_data; /* Any typed data, same type as above */
  41.     XEvent event; /* The actual event */
  42.  
  43. For example:
  44.  
  45.     void button(w, my_data, event)
  46.       Widget w;
  47.       My_Struct my_data;
  48.       XEvent event;
  49.     { 
  50.       XCloseDisplay(XDisplay(w));
  51.       exit(0);
  52.     }
  53.  
  54. would close the display and exit out.
  55.  
  56. So just look up the XEvent structure, extract what you want, then write it
  57. to a file.  Simple, heh?
  58.  
  59. Erik Currin
  60. CS at WPI
  61.