WtAddCallback Function (Motif Only)
Registers a callback routine for a given widget.
Usage
status = WtAddCallback(widget, reason, callback[, client_data])
Input Parameters
widget — The widget ID of the widget to add the callback to (long).
reason — A string containing the callback reason. This parameter is GUI-dependent. See the Discussion section below for more information.
callback — A string containing the name of the callback routine.
client_data — A variable. The value of this variable is passed to the callback routine.
Returned Value
status — One (1) indicates success; zero (0) indicates failure.
Keywords
Noparams — If present and nonzero, the callback is called with two parameters: wid and data. All other parameters, as discussed in Appendix B: Motif Callback Parameters in the PV‑WAVE Application Developer’s Guide.
Discussion
Callback reasons are listed throughout the OSF/Motif Programmer's Reference.
Note: |
The use of WtAddCallback is not supported for Windows. |
To use a callback reason in PV‑WAVE, remove the XmN or XtN prefix. For example, the Motif callback reason XmNactivateCallback would become activateCallback.
The application can optionally use the client_data parameter to specify some application-defined data to be passed to the callback procedure when the callback is invoked. If client_data is a local variable (defined only in the current procedure), a copy of that variable is created and passed (passed by value). If the client_data is a global variable (defined in a Common Block), it is passed by reference.
Example
This example creates a Motif button labeled Done. When you select the button, the widget is destroyed. To run the example, enter the callback and the example procedures in a file and run them with .RUN.
Callback Procedure Example: Motif
This is the callback routine. Note that the callback routine for the pushbutton widget class requires six parameters. The required callback parameters for Motif widget classes are discussed in Appendix A: Motif Widget Classes in the PV‑WAVE Application Developer’s Guide.
PRO CancelHelp, wid, data, npar, reason, event, count
COMMON block, top
status=WtClose(top)
END
Example Procedure
PRO example
COMMON block, top
@wtxmclasses.pro
top=WtInit('wt_ex1', 'Examples')
widget=WtCreate('Done', xmPushButtonWidgetClass, top)
status=WtAddCallback(widget, 'activateCallback', $
'CancelHelp')
status=WtSet(top, /Realize)
WtLoop
END