-
FEATURED COMPONENTS
First time here? Check out the FAQ!
It seems that onClick is always happens no matter the user single or double click a component that supposes to support both onClick and onDoubleClick. By reading 3.6.1 release note, I thought this is fixed. However, it still doesn't work. Is there anyone know any workaround? Thanks.
<window id="wnd" title="Demo" width="400px" border="normal">
<zscript>
void do1() {
Messagebox.show("1");
}
void do2() {
Messagebox.show("2");
}
</zscript>
<tabbox id="tbox" width="100%" onSelect="desktop.bookmark = self.selectedTab.id">
<tabs>
<tab id="tab1" label="Tab 1"/>
<tab id="tab2" label="Tab 2"/>
<tab id="tab3" label="Tab 3"/>
</tabs>
<tabpanels>
<tabpanel>This is panel 1
</tabpanel>
<tabpanel>This is panel 2 </tabpanel>
<tabpanel>This is panel 3
<textbox id="txt_p3" />
Try label: <label value="OnCLick+onDoubleClick" style="text-decoration:underline" width="100px" onClick="do1()" onDoubleClick="do2()"/>
</tabpanel>
</tabpanels>
</tabbox>
</window>
Have you tried to add only onDoubleClick event listener?
<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
<window title="new page title" border="normal">
<label value="test" onClick="alert(1)"/>
<label value="test2" onDoubleClick="alert(2)"/>
<label value="test3" onClick="alert(3)" onDoubleClick="alert(4)"/>
</window>
</zk>
Yes. It works properly if there is only one event listener. However, it is very useful in the web application that allows both click and double clicks on a component which could perform different functions. In your example provided above, no matter how many times you click label 3, it only shows messageBox with value 3. When you try to click (or double clicks) this item multiple time, following errors show up:
org.zkoss.zk.ui.UiException: Replicated UUID is not allowed for class org.zkoss.zul.impl.MessageboxDlg$Button: zid_btn1
>> at org.zkoss.zk.ui.AbstractComponent.setId(AbstractComponent.java:622)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> at java.lang.reflect.Method.invoke(Method.java:585)
>> at org.zkoss.zk.ui.metainfo.Property.assign0(Property.java:260)
>> at org.zkoss.zk.ui.metainfo.Property.assign(Property.java:175)
>> at org.zkoss.zk.ui.metainfo.ComponentInfo.applyProperties(ComponentInfo.java:769)
>> at org.zkoss.zk.ui.impl.AbstractUiFactory.newComponent(AbstractUiFactory.java:95)
Please share your thought how to solve this, thanks,
Hi,
I have no idea how to solve this by zk,
but javascript may help,
<html> <attribute name="content"> <span style="cursor:default" onmouseup="checkClick()" > test </span> <script> var clickRepeat; var clickCount=0; var clickDelay=200; function checkClick() { clearTimeout(clickRepeat); clickCount++; if(clickCount==1) {clickRepeat=setTimeout('function1();clickCount=0',clickDelay);} else {function2();clickCount=0;} } function function1() { alert(0); } function function2() { alert(1); } </script> </attribute> </html>
Asked: 2009-06-02 22:45:31 +0800
Seen: 404 times
Last updated: Jun 04 '09