Using Events
After initialization, all runtime processing is a result of events being dispatched and handled so you need to grok the event system to become a serious qooxdoo application developer.
addEventListener and removeEventListener are only available in instances of classes whose superclass is qx.core.Target. Please take a look at the API documentation.
Adding event listeners
The simplest way to register interest in an event is:
classInstance.addEventListener("eventName", functionPointer);
In this case the function must be named e.g. has to be declared with:
// e is the event object (passed automatically to your listener function) function functionPointer(e) {}
previously. You can also use an inline function like:
// e is the event object (passed automatically to your listener) classInstance.addEventListener("eventName", function(e) {});
Normally a function gets executed in the context of the instance where the event was attached previously. If you don’t want this, you must define the object you want as the context as a third argument:
classInstance.addEventListener("eventName", functionPointer, contextObject);
This binds the this variable inside the callback function functionPointer to contextObject. This could also be used to attach events to execute a method of the current class:
classInstance.addEventListener("eventName", otherClass.functionPointer, otherClass);
Removing event listeners
Removing listeners is as easy as registering new ones:
classInstance.removeEventListener("eventName", functionPointer);
This removes the previously defined named function from the event of the class.
If you want to remove a listener which was defined to execute in another context, you must also add this context argument on the event removal:
classInstance.removeEventListener("eventName", otherClass.functionPointer, otherClass);
