home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!amdahl!JUTS!Holland!gordie
- From: gordie@duts.ccc.amdahl.com (Gordon Freedman)
- Newsgroups: comp.lang.c++
- Subject: Re: C++ and XtAddEventHandler()
- Message-ID: <18ZS02GF1blb01@JUTS.ccc.amdahl.com>
- Date: 24 Jul 92 00:09:51 GMT
- References: <1992Jul20.134344.17048@nuscc.nus.sg>
- Sender: netnews@ccc.amdahl.com
- Reply-To: gordie@duts.ccc.amdahl.com
- Organization: Happy hacker bait and tackle shop
- Lines: 57
-
- In article 17048@nuscc.nus.sg, zhaocuie@iscs.nus.sg () writes:
- >I'm using C++ to develop a GUI builder based on Motif, Xt, and X11.
- >Now I'm facing some problems. I need to call an Xt convienent function
- > XtAddEventHandler(_w, event_mask, nonmaskable, proc, client_data)
- >to popup Motif popup menus. I wrote the codes as follows:
- >
- > void Simple::pop() {
- > ......
- > XtAddEventHandler(_w,
- > ButtonPressMask,
- > False,
- > &Simple::postItEventHandler,
- > (XtPointer) this);
- > ......
- > }
- >
- > void Simple::postItEventHandler(Widget, XtPointer clientData, XtPointer)
- > {
- > Simple *obj = (Simple *) clientData;
- > obj -> postIt();
- > }
- >
- > void Simple::postIt() {
- > .......
- > }
- >
- >It does not work. The compiler said:
- > error: bad argument 4 type for XtAddEventHandler(): void (*) (Widget,
- > XtPointer, XtPointer) (XtEventHandler expected)
- >That means the type of the last argument of XtAddEventHandler() is not
- >properly.
- >Do you know how to call this function properly? Can anyone help me?
- >
- >pl. email: zhaocuie@iscs.nus.sg
- >Thanks for any kind help.
-
-
- You didn't include the definition of the class, but you have to declare the
- function Simple::postItEventHandler as static:
-
- class thing
- {
- private:
- static postItEventHandler (Widget, XtPointer client, XtPointer) ;
- // ...
- public:
- // ...
- } ;
-
- Sorry if you already did this and the problem is something else, but it should
- work (see "Object Oriented Programming with C++ and Motif" by Douglas A. Young
- for an example of something similar using XmNdestroyCallback from within
- a class - page 88).
-
-
- ---
- Gordon Freedman: gjf00@duts.ccc.amdahl.com OOPs, did I code that?
-