Add a single callback entry to a callback list
void PtAddCallback( PtWidget_t *widget, unsigned long callback_type, PtCallbackF_t *callback, void *data );
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; exit( 0 ); } main() { PtArg_t argt; PtWidget_t *window, *widget; window = PtAppInit( NULL, NULL, NULL, 0, NULL ); PtSetArg( &argt, Pt_ARG_TEXT_STRING, "Press Me To Quit", 0 ); button = PtCreateWidget( PtButton, NULL, 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(), PtAddHotkeyHandler(), PtRemoveCallback(), PtRemoveCallbacks()
Creating Widgets in Application Code chapter of the Photon Programmer's Guide