Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pt/ptaddcallback.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pt/ptaddcallback.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pt/ptaddcallback.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pt/ptaddcallback.html on line 8

PtAddCallback()

Add a single callback entry to a callback list

Synopsis:

void PtAddCallback( PtWidget_t *widget,
                    unsigned long callback_type,
                    PtCallbackF_t *callback,
                    void *data );

Arguments:

widget
A pointer to the widget that you want to add the callback to.
callback_type
The name of the callback list you want to add the function to. For example, Pt_CB_ACTIVATE.
callback
A pointer to the function you want to add. The function takes this form:
int (*callback)(PtWidget_t *, void *,
                           PtCallbackInfo_t *)
  
data
A pointer to data that you want to pass as the second argument to the function.

Library:

ph

Description:

This function adds a callback to the callback list indicated by callback_type.


Note: Some types of callback resources have special routines that you should use instead of this one:
Pt_CB_FILTER
PtAddFilterCallback() or PtAddFilterCallbacks()
Pt_CB_HOTKEY
PtAddHotkeyHandler()
Pt_CB_RAW
PtAddEventHandler() or PtAddEventHandlers()

Examples:

#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;
}

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

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


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pt/ptaddcallback.html on line 207

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pt/ptaddcallback.html on line 207