Adding Callbacks (Motif Only)
Most widgets provide “hooks” that call particular procedures when a predefined condition occurs. These hooks are known as callback lists and the procedures are called callbacks. To add a callback to a widget’s callback list, use the WtAddCallback function:
status = WtAddCallback(wid, reason, procedure, [client_data])
note | Rogue Wave has ported a subset of the Widget Toolbox (Wt) functionality that is available for Motif to Microsoft Windows. Because the Widget Toolbox under Windows is not a complete implementation, we recommend that Windows developers use the PV-WAVE 10.0 Widgets (Ww) layer or the VDA Tools when developing GUI applications. |
The wid parameter is the ID of the widget to add the callback to. The reason parameter is a string that specifies the callback list to which the callback routine (function or procedure) is to be added. The reason name is derived from the Motif reason name. Remove the XmN prefix from the Motif reason names. For example the Motif reason name, XmNactivateCallback, becomes the Widget reason name 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.
The form of every Widget Toolbox callback procedure is:
PRO CallbackProc, widget, client_data, $
nparams, [p1, p2, ... pn]
where:
widget—The widget ID.
client_data—The
client_data passed to WtAddCallback.
nparams—The number of callback-specific parameters after
nparams. Two additional parameters are required:
event and
reason. For information on these additional parameters, see
Motif Callback Parameters.
Example
This example adds a callback called quitit to the callback list for the widget warr(2). The callback reason is activateCallback.
status=WtAddCallback(warr(2), 'activateCallback', 'quitit')
See the example Widget Toolbox application at the end of this chapter.
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.