/* cb.uil − Plain and simple callback setting example. */
module cb
procedure
print (string);
quit();
object Hello : XmPushButton {
callbacks {
XmNactivateCallback = procedure print ("hello!");
};
};
object Goodbye : XmPushButton {
callbacks {
XmNactivateCallback = procedures {
print ("goodbye!");
quit();
};
};
};
object root : XmRowColumn {
controls {
XmPushButton Hello;
XmPushButton Goodbye;
};
};
end module;
The callback declarations in the procedure section tell the UIL compiler that the procedures are defined externally
in the application program. A callback setting looks similar to a resource setting; it always begins with the name of a
callback, such as XmNactivateCallback, and is followed by an equal sign. The right−hand side of the setting
varies depending on the number of callback procedures you are specifying. A single callback is specified with the
keyword procedure followed by the callback invocation. Multiple callbacks are specified with the keyword
procedures followed by a list of callback invocations.
In the source code the XmNactivateCallback of the Hello PushButton is set to the single callback procedure
print(), while the XmNactivateCallback of the Goodbye PushButton is set to the two callbacks print()
and quit(). You cannot specify multiple callbacks by setting the same callback more than once because when you
set the same resource or callback multiple times, only the last setting is used. The Xt specification doesn't guarantee
the order in which callbacks are called, ...