Package com.openinventor.inventor.misc
Class Callback
java.lang.Object
com.openinventor.inventor.misc.Callback
- All Implemented Interfaces:
CB
- Direct Known Subclasses:
NCallback
This class is intended to be subclassed in order to invoke a particular
method for a given object. The method invoke is used by callback lists
to invoke all callbacks in their lists or by native callbacks to bind java
and native callbacks.
When a callback is registered, it is paired with a user data object which can be used when the callback is called. This object is stored in the userData field. The documentation does not mention the userData field since it is a protected field.But all classes subclassing Callback have access to this field. Its definition is : protected Object userData. Note that the content of userData is not the object passed as a parameter to any invoke method.
For instance:
When a callback is registered, it is paired with a user data object which can be used when the callback is called. This object is stored in the userData field. The documentation does not mention the userData field since it is a protected field.But all classes subclassing Callback have access to this field. Its definition is : protected Object userData. Note that the content of userData is not the object passed as a parameter to any invoke method.
For instance:
[...] callbacks.addCallback(new MyCallback(), myObject) ; [...] callbacks.invokeCallbacks(anObject) ; class MyCallback extends Callback { public void invoke(Object data) { MyClass myObject = (myClass) userData ; AClass anObject = (AClass) data ; [...] } }
-
Constructor Summary
Constructors -
Method Summary