You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Federico Fanton <ff...@ibc.it> on 2007/10/01 10:21:37 UTC

Re: Onclick and ondblclick on same element

On Fri, 28 Sep 2007 16:43:05 +0200
Federico Fanton <ff...@ibc.it> wrote:

> My problem is that when I double click on the row three events are fired: two onclick and one ondblclick.. Is this normal? Is there a way to isolate the last event and ignore the first two?

I googled some more, and found that usually the workaround is to set a timeout for the onclick function, so that if ondblclick gets fired before the timeout, it cancels the onclick and goes on about its business.. Is there a Wicket behavior that works this way, perhaps? ^__^; I could extend AbstractAjaxTimerBehavior maybe..

Many thanks for your time!


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Onclick and ondblclick on same element

Posted by Federico Fanton <ff...@ibc.it>.
On Mon, 1 Oct 2007 02:10:13 -0700 (PDT)
swaroop belur <sw...@gmail.com> wrote:

> b1.setThrottleDelay(Duration.valueOf(1000)); // Make sure dbl click happens before onclick

So the delay takes place *before* the first event, not after? I see.. Many thanks! :)


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Onclick and ondblclick on same element

Posted by swaroop belur <sw...@gmail.com>.
Hi

Try this out . This may surely not be the best way to do it.
Here when u dbl click, the single click event still occurs...but i am using
a variable to detect whether dbl click event happened before or not.
In that case, i simply return after toggling back.


Click Test 

<code>
                WebMarkupContainer click = new WebMarkupContainer("click");
		click.setOutputMarkupId(true);
		AjaxEventBehavior b1 = new AjaxEventBehavior("onclick"){

			@Override
			protected void onEvent(AjaxRequestTarget target) {
				if(dblclickevent){
					dblclickevent = false;
					return;
				}
				target.appendJavascript("alert('onclick occurred');");
				dblclickevent = false;
			}
		
		};
		
                b1.setThrottleDelay(Duration.valueOf(1000)); // Make sure
dbl click happens before onclick

		click.add(b1);

		AjaxEventBehavior b2 = new AjaxEventBehavior("ondblclick"){

			@Override
			protected void onEvent(AjaxRequestTarget target) {
				target.appendJavascript("alert('ondblclick occurred');");
				dblclickevent = true;
			}

			
		};
		click.add(b2);
		add(click);
</code>

-swaroop


Federico Fanton wrote:
> 
> On Fri, 28 Sep 2007 16:43:05 +0200
> Federico Fanton <ff...@ibc.it> wrote:
> 
>> My problem is that when I double click on the row three events are fired:
>> two onclick and one ondblclick.. Is this normal? Is there a way to
>> isolate the last event and ignore the first two?
> 
> I googled some more, and found that usually the workaround is to set a
> timeout for the onclick function, so that if ondblclick gets fired before
> the timeout, it cancels the onclick and goes on about its business.. Is
> there a Wicket behavior that works this way, perhaps? ^__^; I could extend
> AbstractAjaxTimerBehavior maybe..
> 
> Many thanks for your time!
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Onclick-and-ondblclick-on-same-element-tf4534962.html#a12975648
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org