Path: utzoo!news-server.csri.toronto.edu!rutgers!hsdndev!spdcc!tauxersvilli!alphalpha!nazgul From: nazgul@alphalpha.com (Kee Hinckley) Newsgroups: comp.windows.x Subject: Re: C++ and X: Member-Functions as Callbacks Message-ID: <1991Mar10.021700.19538@alphalpha.com> Date: 10 Mar 91 02:17:00 GMT References: <1991Mar9.123358.14352@csn.org> Organization: asi Lines: 29 In article <1991Mar9.123358.14352@csn.org> rink@tramp.colorado.edu (Jeff) writes: > > >Howdy. >Help requested from C++ and X gurus: > > > I am trying to set up a callback for an X widget. I would LIKE > to have the callback be a member-function of a C++ class. > An example: The only way you can make this work is to declare the member function static. Then it's up to you to figure out how to pass "this". The easiest way is in the the callback data, the second easiest is in the widgets userData resource. It would be nice if C++ allowed you to then assign this and proceed normally, but.... If you want to do virtual functions, declare two callbacks, one static and one virtual. All the static one does is call the virtual one. -kee -- Alfalfa Software, Inc. | Poste: The EMail for Unix nazgul@alfalfa.com | Send Anything... Anywhere 617/646-7703 (voice/fax) | info@alfalfa.com I'm not sure which upsets me more: that people are so unwilling to accept responsibility for their own actions, or that they are so eager to regulate everyone else's.