Next: Finishing off - displaying widgets and event Up: Events and Callbacks Previous: Adding callbacks

Declaring callback functions

Let us now look at the declaration of the application defined callback function. All callback functions have this form.


void pushed_fn(Widget w, XtPointer client_data, 
               XmPushButtonCallbackStruct *cbs)

The first parameter of the function is the widget associated with the function (button in our case).

The second parameter is used to pass client data to the function. We will see how to attach client data to a callback later in the course. We do not use it in this so just leave it defined as above for now. We will see how to attach client data to a callback later in the course.

The third parameter is a pointer to a structure that contains data specific to the particular widget that called the function and also information about the event that triggered the call.

The structure we have used is a XmPushButtonCallbackStruct. A Callback Structure has the following general form:


typedef struct {
     int reason;
     XEvent *event;
     .... widget specifics ...
} Xm<widget>CallbackStruct;

The reason contains information about the callback such if arm or disarm invoked the call.

event is a pointer to an (Xlib) XEvent structure that contains information about the event.


Dave.Marshall@cm.cf.ac.uk
Tue May 24 16:52:56 BST 1994