When overriding a component by use of your own class, you could declare a member function to be an event listener as follows.
In a ZUML page, you declare the use attribute to specify what class you want to use instead of the default one. As illustrated below, it asks ZK to use the MyWindow class instead of org.zkoss.zul.Window[30].
<window use="MyWindow"> ... </window>
Then, you implement MyWindow.java by extending from the default class as follows.
public class MyWindow extends org.zkoss.zul.Window { public void onOK() { //add an event listener ...//handles the onOK event (sent when ENTER is pressed) } }
If you want to retrieve more information about the event, you could declare as follows.
public void onOK(org.zkoss.zk.ui.event.KeyEvent event) {...}
or
public void onOK(org.zkoss.zk.ui.event.Event event) {...}
Different events might be associated with different event objects. Refer to Append C for more details.