Up |
_OBJsetCBfromOldAll
Change the current callback used to any event by a new one.
Same thing for the user parameter.
Thus, all the events (for one object) which set a same callback will be changed.
Prototype :
fun [u0 u1 u1 u2 I] I
- u0 : a Scol object
- u1 : the current callback (by example : @myOldCallbackForThisEvent)
- u1 : the new callback to set, can be nil to ignore this event (by example : @myNewCallbackForThisEvent).
- u2 : the new user parameter to set
- 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.
See also :
- _OBJgetCB
- _OBJsetCB
- _OBJsetCBfromOld for the first occurence only
Example :
typeof win = ObjWin;;
fun cb_common2 (o, u)=
_fooId u*2;;
fun cb_common (o, u)=
_fooId u;;
fun main ()=
_showconsole;
// ...
set win = _CRwindow _channel nil 200 250 400 500 WN_NORMAL "A";
_fooId _OBJsetCB win 7 @cb_common 7 0; // or _CBwinDestroy win @cb_destroy 7;
_CBwinKillFocus win @cb_common 5;
// ...
// KillFocus and Destroy events are changed, the user parameter is unchanged (flag is set to 1)
_fooId _OBJsetCBfromOldAll win @cb_common @cb_common2 11 1;
// ...
0;;
Note :
This functions sets all occurences found
For be safer, the old and the new callback must have the same prototype. Else, the VM will crash. In the future, we may authorize another prototype. In this case, this will have no effect on the previous Scol written source code.
Thus, the old and new user parameters must have the same type. In the future, this behavior could be modified by us. If any, it will be no effect for existing source code.
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.
Of course, the developer should directly call the reflex definition function (for example _CBwinDestroy in the example above). _OBJsetCBfromOldAll is another way to set multiple CB or what he/she wants !