Document Information

Last modified:
2007/12/01 23:02 by hughgibson

This is documentation for qooxdoo 0.7.x only. You might be interested in consulting the latest docs.

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.

The required methods 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.

To remove an event listener you need access to the function pointer. It’s impossible to remove an event listener without knowing the function. This makes clear why inline defined functions for event listeners may be problematic, namely when you want to remove them later.

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);

Information

Last modified:
2007/12/01 23:02 by hughgibson

Account

Not logged in

 
 

Rich Ajax Platform (RAP)

RAP uses qooxdoo, Java and the Eclipse development model to build rich web applications. Read more...

qooxdoo Web Toolkit (QWT)

Similar to GWT this framework allows to create impressive qooxdoo applications just using Java. Read more...

Pustefix

Pustefix is a MVC-based web application framework using Java and XML/XSLT. Read more...

 
SourceForge.net Logo

Bad Behavior has blocked 0 potential spam attempts in the last 7 days.