chan@icsid2.comp (Pamela Chan) (06/24/91)
I'm a beginner in InterViews and I'm currently working with
InterViews 3.0b.
This is probably a silly question but I do want to know
the answer....
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:
/////////////////////////////////////////////////////////
class TestButton {
public:
TestButton(){};
~TestButton(){};
void Press(){
fprintf (stderr, "Test button pressed\n");
};
};
declare(ActionCallback, TestButton)
implement(ActionCallback, TestButton)
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),
new ChoiceItem(
new Bevel(new Margin(new Label("Test", f, fg), 3.0),
new Outset(color)),
new Bevel(new Margin(new Label("Test", f, fg), 3.0),
new Inset(color))
)
);
========================================================
"main.c", line 31: error: bad argument list for
TestButton_ActionCallback::TestButton_ActionCallback()
(no match against any TestButton_ActionCallback::TestButton_ActionCallback())
1 error
/////////////////////////////////////////////////////
I'm not sure what's declare() and implement() and
I'm only following the example blindly.
Can anyone explain to me what's wrong with my callback function?
Thanks.
------------------------------------------------------------------------
Pamela Chan International Computer Science Institute
chan@icsi.berkeley.edu 1947 Center Street, Berkeley, CAlinton@marktwain.rad.sgi.com (Mark Linton) (06/24/91)
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.