Add a single callback entry to a callback list
void PtAddCallback( PtWidget_t *widget,
unsigned long callback_type,
PtCallbackF_t *callback,
void *data );
ph
This function adds a callback to the callback list indicated by callback_type (e.g. Pt_CB_ACTIVATE).
| Some types of callback resources have special routines that you should use instead of this one: |
The callback argument points to a function that takes this form:
int (*callback)(PtWidget_t *, void *, PtCallbackInfo_t *)
activated( PtWidget_t *widget, void *data,
PtCallbackInfo_t *info)
{
//suppress compiler warnings concerning unused arguments.
widget = widget, data = data, info = info;
PtExit( 0 );
}
main()
{
PtArg_t argt;
PtWidget_t *window, *widget;
if (PtInit(NULL) == -1)
PtExit(EXIT_FAILURE);
if ((window = PtCreateWidget(PtWindow, Pt_NO_PARENT,
0, NULL)) == NULL)
PtExit(EXIT_FAILURE);
PtSetArg( &argt, Pt_ARG_TEXT_STRING,
"Press Me To Quit", 0 );
button = PtCreateWidget( PtButton, Pt_DEFAULT_PARENT,
1, &args );
//add an activate callback to the button.
PtAddCallback( button, Pt_CB_ACTIVATE,
activated, NULL );
PtRealizeWidget( window );
PtMainLoop();
//unnecessary
PtRemoveCallback( button, Pt_CB_ACTIVATE,
activated, NULL );
}
Photon
| Safety: | |
|---|---|
| Interrupt handler | No |
| Signal handler | No |
| Thread | No |
PtAddCallbacks(), PtAddEventHandler(), PtAddEventHandlers(), PtAddFilterCallback(), PtAddFilterCallbacks(), PtAddHotkeyHandler(), PtRemoveCallback(), PtRemoveCallbacks()
PtCallbackInfo_t in the Photon Widget Reference
Creating Widgets in Application Code chapter of the Photon Programmer's Guide