home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11445 < prev    next >
Encoding:
Text File  |  1992-07-23  |  2.0 KB  |  70 lines

  1. Path: sparky!uunet!charon.amdahl.com!amdahl!JUTS!Holland!gordie
  2. From: gordie@duts.ccc.amdahl.com (Gordon Freedman)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: C++ and XtAddEventHandler()
  5. Message-ID: <18ZS02GF1blb01@JUTS.ccc.amdahl.com>
  6. Date: 24 Jul 92 00:09:51 GMT
  7. References: <1992Jul20.134344.17048@nuscc.nus.sg>
  8. Sender: netnews@ccc.amdahl.com
  9. Reply-To: gordie@duts.ccc.amdahl.com
  10. Organization: Happy hacker bait and tackle shop
  11. Lines: 57
  12.  
  13. In article 17048@nuscc.nus.sg, zhaocuie@iscs.nus.sg () writes:
  14. >I'm using C++ to develop a GUI builder based on Motif, Xt, and X11.
  15. >Now I'm facing some problems. I need to call an Xt convienent function
  16. >    XtAddEventHandler(_w, event_mask, nonmaskable, proc, client_data)
  17. >to popup Motif popup menus. I wrote the codes as follows:
  18. >
  19. >    void Simple::pop() {
  20. >            ......
  21. >            XtAddEventHandler(_w,
  22. >                      ButtonPressMask,
  23. >                      False,
  24. >                      &Simple::postItEventHandler,
  25. >                      (XtPointer) this);
  26. >            ......
  27. >               }
  28. >
  29. >    void Simple::postItEventHandler(Widget, XtPointer clientData, XtPointer)
  30. >            {
  31. >                Simple *obj = (Simple *) clientData;
  32. >                obj -> postIt();
  33. >            }
  34. >
  35. >    void Simple::postIt() {
  36. >            .......
  37. >              }
  38. >
  39. >It does not work. The compiler said:
  40. >    error: bad argument 4 type for XtAddEventHandler(): void (*) (Widget,
  41. >    XtPointer, XtPointer) (XtEventHandler expected)
  42. >That means the type of the last argument of XtAddEventHandler() is not
  43. >properly.
  44. >Do you know how to call this function properly? Can anyone help me?
  45. >
  46. >pl. email: zhaocuie@iscs.nus.sg
  47. >Thanks for any kind help.
  48.  
  49.  
  50. You didn't include the definition of the class, but you have to declare the 
  51. function Simple::postItEventHandler as static:
  52.  
  53. class thing 
  54. {
  55. private:
  56.     static postItEventHandler (Widget, XtPointer client, XtPointer) ;
  57. // ...
  58. public:
  59. // ...
  60. } ;
  61.  
  62. Sorry if you already did this and the problem is something else, but it should
  63. work (see "Object Oriented Programming with C++ and Motif" by Douglas A. Young
  64. for an example of something similar using XmNdestroyCallback from within
  65. a class - page 88).
  66.  
  67.  
  68. ---
  69. Gordon Freedman: gjf00@duts.ccc.amdahl.com OOPs, did I code that?
  70.