0

ZK 3.6.1 doesn't support both onClick and onDoubleClick

asked 2009-06-02 22:45:31 +0800

ccmyers gravatar image ccmyers
102 1 1

updated 2009-06-02 22:49:59 +0800

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>

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2009-06-03 11:12:03 +0800

PeterKuo gravatar image PeterKuo
481 2

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>

link publish delete flag offensive edit

answered 2009-06-03 15:37:53 +0800

ccmyers gravatar image ccmyers
102 1 1

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,

link publish delete flag offensive edit

answered 2009-06-04 02:07:33 +0800

hideokidd gravatar image hideokidd
750 1 2

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>

link publish delete flag offensive edit

answered 2009-06-04 14:43:11 +0800

ccmyers gravatar image ccmyers
102 1 1

Thanks for your time.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-06-02 22:45:31 +0800

Seen: 404 times

Last updated: Jun 04 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More