![]() |
![]() |
![]() |
![]() |
![]() |
This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Add a single callback entry to a callback list
void PtAddCallback( PtWidget_t *widget,
unsigned long callback_type,
PtCallbackF_t *callback,
void *data );
int (*callback)(PtWidget_t *, void *,
PtCallbackInfo_t *)
ph
This function adds a callback to the callback list indicated by callback_type.
![]() |
Some types of callback resources have special routines that you should use instead of this one: |
#include <stdlib.h>
#include <Pt.h>
int activated( PtWidget_t *widget, void *data,
PtCallbackInfo_t *info)
{
//suppress compiler warnings concerning unused arguments.
widget = widget, data = data, info = info;
PtExit( 0 );
return Pt_CONTINUE;
}
int main()
{
PtArg_t args;
PtWidget_t *window, *button;
if (PtInit(NULL) == -1)
exit(EXIT_FAILURE);
if ((window = PtCreateWidget(PtWindow, Pt_NO_PARENT,
0, NULL)) == NULL)
PtExit(EXIT_FAILURE);
PtSetArg( &args, 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 );
return EXIT_SUCCESS;
}
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
Managing Widgets in Application Code chapter of the Photon Programmer's Guide
![]() |
![]() |
![]() |
![]() |