🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.interviews
Article #1520

Re: Callback Functions in 3.0b

#1520
From: Mark Linton
Date: Mon, 24 Jun 1991 16:13
25 lines
1805 bytes
In article <CHAN.91Jun23132258@icsid2.comp>, chan@icsid2.comp (Pamela Chan) writes:
|> I'm trying to associate a callback funtion with a simple 
|> push button. I was looking at the sample program <alert.c> 
|> in the standard distribution. It works fine if I assigned 
|> World::quit as the callback function, but anything else will 
|> generate a compiler error:
|> 
|> Glyph* MakeControlPanelDialog(Font* f, Color* fg, TestButton* tbutton) {
|> 
|>    Button* button1 = new Button(
|> 
|> //   *******error occurs here**********
|>      new ActionCallback(TestButton) (&tbutton, TestButton::Press),
|> 
|> //   replace the above line with the following and it works fine
|> //   new ActionCallback(World) (&world, &World::quit),
|> 
|> "main.c", line 31: error: bad argument list for 
|> TestButton_ActionCallback::TestButton_ActionCallback() 
|> (no match against any  TestButton_ActionCallback::TestButton_ActionCallback())
|> 1 error

The problem is you pass ``&tbutton'' instead of ``tbutton''.  The constructor wants
a pointer to a TestButton (or more generally the callback receiver type).  The alert program
uses ``&world'' because world is declared as an object instead of a pointer.
Technical Details
Message-ID: <1991Jun24.161307.2804@fido.asd.sgi.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!sgi!shinobu!fido.asd.sgi.com!marktwain.rad.sgi.com!linton
References: <CHAN.91Jun23132258@icsid2.comp>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!sgi!shinobu!fido.asd.sgi.com!marktwain.rad.sgi.com!linton
From: linton@marktwain.rad.sgi.com (Mark Linton)
Newsgroups: comp.windows.interviews
Subject: Re: Callback Functions in 3.0b
Message-ID: <1991Jun24.161307.2804@fido.asd.sgi.com>
Date: 24 Jun 91 16:13:07 GMT
References: <CHAN.91Jun23132258@icsid2.comp>
Sender: news@fido.asd.sgi.com (Usenet News Admin)
Reply-To: linton@marktwain.rad.sgi.com (Mark Linton)
Distribution: comp
Organization: sgi
Lines: 25