-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have run into an issue with the Listbox selection model. The way the listbox works is if you select a row, then click it again, you DO NOT receive the onSelect for the second click. I am trying to change the way the selection works for a multi-select listbox I have.
What I want is the first click on a row to select it, the second click on the same row to deselect it - this is easy to do if the second click triggered the onSelect handler - but it doesn't. I have looked at the methods in the parent for a way to intercept the mouse event and couldn't see anything obvious.
My question - How can I make each click on a row trigger the onSelect handler, regardless of whether I already click on that row or not?
Please use the onClick event instead.
It appears that the listbox does not respond to the onClick event. I tried the following since I am using a Composer.
The id of my listbox in the .zul is _zonesListBox and the associated Listbox member of my composer is _zonesListBox :
public void onClick$_zonesListBox(Event event) { // THIS NEVER GETS CALLED }
I also tried in the ZKDemo just to test using the attribute tag in a listbox :
<listbox width="250px"> <attribute name="onClick">.........
And this was never called either. When I changed the attribute to onSelect it was called.
Here is my full .zul (dhZoneListbox overrides Listbox in lang-addon.xml)
<dhITouchWindow id="DHzZonesWindow" apply="com.dh.ui.itouch.composer.zone.DHzZonesComposer"> <zscript> DHzZonesWindow.setAction("onhide:anima.fade(#{self})"); </zscript> <dhVbox> <dhZoneListbox multiple="true" style="margin-bottom:5px" width="100%" id="_zonesListBox"/> </dhVbox> <dhHbox> <button label="OK" id="_okButton"/> </dhHbox> </dhITouchWindow>
And here is the relevant portions of the Composer :
public class DHzZonesComposer extends GenericForwardComposer implements Initiator { private static final Logger logger = Logger.getLogger(DHzZonesComposer.class); private DHzZoneModel _zoneModel = new DHzZoneModel(); private DHzZoneList _zonesListBox; private Button _okButton; ..... /** * * Method : onClick$_zonesListBox * * @param event */ public void onClick$_zonesListBox(Event event) { // THIS IS NEVER CALLED }
More info, I added in my composer as an eventListener to the listbox (this is the composer)
_zonesListBox.addEventListener("onClick", this);
And in the onEvent handler of the composer the following code. This get's called same as the onSelect, if you select one row then another it gets called, if you try and select the same row twice, the first click generates an event, the second does not.
/** * Method : onEvent * * @see org.zkoss.zk.ui.event.GenericEventListener#onEvent(org.zkoss.zk.ui.event.Event) * * @param arg0 * @throws Exception */ @Override public void onEvent(Event event) throws Exception { super.onEvent(event); logger.info("DHzZonesComposer::onEvent, Event Name = " + event.getName()); }
I have tried in the Debugger to find where the event is getting swallowed the second time you click a row in the listbox, can one of the ZK team please let me know which class is intercepting the mouse event and then deciding not to pass it along?
I walked the call stack trying to set breakpoints to capture it so I can change the behavior with no luck.
Neither onClick nor onSelect get passed along if a row is already selected, help greatly appreciated,
Asked: 2008-09-25 18:50:20 +0800
Seen: 513 times
Last updated: Oct 02 '08