Project

General

Profile

Up

_OBJsetCB

Define the callback and the user parameter for a given object and for a number event.

Change the current callback by another one.

Prototype :

fun [u0 I u1 u2 I] I

  • u0 : a Scol object
  • I : the number event (depends of the type of the object)
  • u1 : the new callback, can be nil to ignore this event.
  • u2 : the new user parameter
  • I : a flag : 0 to set callback AND user parameter, 1 to set the callback only, 2 to set the user parameter only. Default : 0.

Return : I 0. It returns nil if error.

Error :

  • EOK if success.
  • EARGNIL if the given object is nil.
  • ENOFOUND if a required internal object is not found, maybe a system object already deleted.
  • EINVAL if the given number is out of range (depends on each object type).

See also :

Example :

typeof win = ObjWin;;

fun cb_destroy (o, u)=
	_fooId u;;	// Console : 7
	
fun main ()=
	_showconsole;
	// ...
	set win = _CRwindow _channel nil 200 250 400 500 WN_NORMAL "A";
	// ...
	_fooId _OBJsetCB win 7 @cb_destroy 7 0;
	// ...
	0;;

Note :

At this time, the type of the new callback is NOT checked. The developer should check it otherwise the VM can crash.

The old link and the old user parameter are lost. If any, you can store them before change by calling _OBJgetCB. This change is done immediately until another call, if any.

TO DO : at this time, it is not "user friendly" to obtain the event number : the user must look for it from the object source code. We add progressively this number in the callback documentation.

Of course, the developer should directly call the reflex definition function (for example _CBwinDestroy in the example above). _OBJsetCB is another way to set multiples CB or what he/she wants !