Events of UI Components"

From Documentation
Line 14: Line 14:
 
Please look it up at [http://books.zkoss.org/wiki/ZK_Component_Reference Developer's Reference]. For example, [http://books.zkoss.org/wiki/ZK_Component_Reference/Essential_Components/Button<tt>button</tt>] supports <tt>onClick</tt>, <tt>onRightClick</tt>, <tt>onDoubleClick</tt>, <tt>onFocus</tt>, <tt>onBlur</tt> events.
 
Please look it up at [http://books.zkoss.org/wiki/ZK_Component_Reference Developer's Reference]. For example, [http://books.zkoss.org/wiki/ZK_Component_Reference/Essential_Components/Button<tt>button</tt>] supports <tt>onClick</tt>, <tt>onRightClick</tt>, <tt>onDoubleClick</tt>, <tt>onFocus</tt>, <tt>onBlur</tt> events.
  
Due to ZK's fast evolution, if the Developer's Reference is out of sync, please refer to this [[TraceToKnowSupportedEvents|How-To]] to find out what events a component support by tracing source code.
+
Due to ZK's fast evolution, if the Developer's Reference is out of sync, please refer to this [http://books.zkoss.org/wiki/ZK_Component_Reference/Events How-To] to find out what events a component support by tracing source code.
  
 
===Event Processing is limited to desktop scope===
 
===Event Processing is limited to desktop scope===

Revision as of 08:48, 26 July 2010

Events of UI Components


Stop.png This documentation is for an older version of ZK. For the latest one, please click here.



An event (Event ) is used to notify application what happens. Each type of event is represented by a distinct class. For example, MouseEvent represents a mouse activity, such as clicking.

To respond to an event, an application must register one or more event listeners to it. Here are the ways to register an event listener:

  • By specifying the predefined event handler onXxx in the markup language.
  • By calling the addEventListener method for the component or the page you want to listen to.
  • By specifying ZK attributes forward, use, apply. Please refer to The forward Attribute for more information.

In addition to event triggered by user's activity at the browser, an application could fire events by using sendEvent, postEvent and echoEvent methods from the Events class.(Note: These api has to take care about component life cycle, if you use these api outside ZK event handler, please refer to server push.)

How to find out what events a component support

Please look it up at Developer's Reference. For example, button supports onClick, onRightClick, onDoubleClick, onFocus, onBlur events.

Due to ZK's fast evolution, if the Developer's Reference is out of sync, please refer to this How-To to find out what events a component support by tracing source code.

Event Processing is limited to desktop scope

As mentioned above, a desktop is a collection of pages for serving the same URL request. A desktop is also the scope that an event listener could access.

When an event is fired, it is associated with a desktop. ZK separates events by their associated desktops, and pipelines events into separated queues. Therefore, events for the same desktop are processed sequentially. On the other hand, events for different desktops are processed in parallel.

An event listener is allowed to access any component of any page of the associated desktop. It is also allowed to moving components from one page to another as long as they are in the same desktop. On the other hand, it cannot access components belonging to other desktops.



Last Update : 2010/07/26

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.