This example, ex_PtQueryCallbacks.g, is included in the gamma_ph_#_examples_1_QNX4.tgz file available on the Cogent Web Site.
#!/usr/cogent/bin/phgamma
/*
This code puts up a window with a button. Pressing the button creates
two text boxes. The second box displays the return value of the
PtQueryCallbacks() call. Also, each time the button is pressed, the
return value is printed.
*/
require_lisp("PhotonWidgets");
PtInit(nil);
win = new(PtWindow);
win.SetDim(200,200);
PtRealizeWidget(win);
button = new(PtButton);
button.text_string = "Press Here.";
button.SetPos(60,20);
PtAttachCallback(button, Pt_CB_ACTIVATE, #title());
PtAttachCallback(button, Pt_CB_ACTIVATE, #functionlist());
PtRealizeWidget(button);
function title()
{
txt = new(PtText);
txt.SetPos(30,80);
txt.SetDim(150,25);
a = PtQueryCallbacks(button, Pt_CB_ACTIVATE);
txt.text_string = string("The callback functions:");
PtRealizeWidget(txt);
}
function functionlist()
{
txt = new(PtText);
txt.SetPos(30,115);
txt.SetDim(150,25);
c = PtQueryCallbacks(button, Pt_CB_ACTIVATE);
txt.text_string = string(c);
princ(c,"\n");
PtRealizeWidget(txt);
}
PtMainLoop();