[Previous] [Contents] [Index] [Next]

PtAddEventHandler()

Add a single event handler entry to a widget

Synopsis:

void PtAddEventHandler( PtWidget_t *widget,
                        unsigned long event_mask,
                        PtCallbackF_t *callback,
                        void *data );

Description:

This function adds the specified callback to the Pt_CB_RAW callback list that belongs to widget. The widget invokes this callback whenever an event type that matches one of the bits in event_mask intersects with the widget.

The callback argument points to a function that takes this form:

int (*callback)(PtWidget_t *, void *, PtCallbackInfo_t *)

Examples:

PtWidget_t *widget;

PtRawCallback_t callbacks[] = {
    Ph_EV_PTR_MOTION_BUTTON,
    motion_button_callback,
    NULL, 
    Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE, 
    start_end_callback,
    "some data"
}
...
//add both event handlers
PtAddEventHandlers( widget, callbacks, 2 );
...
//remove both event handlers
PtRemoveEventHandlers( widget, callbacks, 2 );
...
//add the motion button event handler
PtAddEventHandler( widget, Ph_EV_PTR_MOTION_BUTTON, 
                   motion_button_callback, NULL );
...
//remove the motion button event handler
PtRemoveEventHandler( widget, Ph_EV_PTR_MOTION_BUTTON, 
                      motion_button_callbacks, NULL )
...
//add both event handlers
PtAddEventHandlers( widget, callbacks, 2 );
...
//remove the motion button event handler
PtRemoveEventHandler( widget, Ph_EV_PTR_MOTION_BUTTON, 
                      motion_button_callbacks, NULL )

// at this point widget still has the Ph_EV_BUT 
// Press/Release event handler 

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PtRemoveEventHandler(), PtAddCallback(), PtAddCallbacks(), PtAddEventHandlers(), PtAddHotkeyHandler()


[Previous] [Contents] [Index] [Next]