
5 The MLWorks Motif Interface Library
Xm.Callback.add. This takes three arguments: the widget, the name of the callback, and the callback function itself.The name of the callback is given by a constructor of the type:
Xm.Callback.nameThe callback function argument has the following type:
Xm.Callback.callback_data -> unitThe
Xm.Callback.callback_data type is an abstract type. The conversion functions in the Xm.Callback structure convert values of the abstract type to concrete data. The system does not check that the user has called the appropriate conversion function for the particular callback.
There is an extra complication with ModifyVerify callbacks. If the program needs to prevent the modification from occurring, it must set a boolean value in the C structure. The Xm structure provides this functionality using the Xm.Boolean structure. This provides an abstract type that corresponds to the location in the C structure, and a function that can set an occurrence of the abstract type to either true or false.
Here is an example:
val text = Xm.Widget.create ...fun modifyVerify callback_data = let val (_,_,doit,_,_,start_pos,end_pos,str) = Xm.Callback.convertTextVerify data in if ... then Xm.Boolean.set (doit, true) else (Xm.Display.bell (Xm.Widget.display text, 0) Xm.Boolean.set (doit, false)) end
Xm.Callback.add (text, Xm.Callback.MODIFY_VERIFY, modifyVerify)

Generated with Harlequin WebMaker