-
15 Feb 2007 4:18 PM #1
how to stop click event when having dblclick event
how to stop click event when having dblclick event
Hi,
A simple question, how do i stop the click event from happening (twice) when i also have a dbl click event listener and in case of a double click only want the dbl click code to run (and so not the click code).
Thanks!
Seldon
-
15 Feb 2007 6:35 PM #2
Check this out: http://www.activewidgets.com/javascr...ick-event.html
Code:var isDoubleClickEvent; var clickAction = function(src) { isDoubleClickEvent = false; setTimeout(performClickAction, 500, src); } var performClickAction = function(src) { if (!isDoubleClickEvent) { // My single click event handler code .. .. } } var doubleClickAction = function(src) { isDoubleClickEvent = true; // My double click event handler code .. .. }
-
15 Feb 2007 7:56 PM #3
I don't think that code works - it certainly missing at least one line to fire the doubleclick code. This snippet does work, although there may be a better way.
Code:var lastClick = 0; var wtf = getEl('wtf'); wtf.mon('click', this.clickTest, this, true); ... clickTest: function(e) { var time = new Date().getTime(); if (time-lastClick < 400) { lastClick = 0; this.onDblClick(e); } else { lastClick = time; this.onClick(e); } }, onClick: function(e) { var el = getEl(e.getTarget()); el.update('1'); }, onDblClick: function(e) { var el = getEl(e.getTarget()); el.update('2'); },Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
16 Feb 2007 1:33 AM #4
I was hoping there would be a more yui-ext like way? Using stopevent or prevendefault in some way?
-
16 Feb 2007 7:57 AM #5
There's no magic way to do this that I know of. Unlike a windows app, click and doubleclick are not separate events at the browser level. You're basically simulating a doubleclick event by virtue of how close together 2 clicks occur - in this case <400ms.
Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
8 Nov 2011 12:31 AM #6
The more ExtJS like way would be:
The double click timeout of 500ms is default on windows, so I think that it's the most appropriate value here.Code:var delayedClick=new Ext.util.DelayedTask(function(){ if(doubleClick)onDblClick(); else onClick() }); wtf.on('click',function(){ doubleClick=false; delayedClick.delay(500) }); wtf.on('dblclick',function(){ doubleClick=true; delayedClick.delay(500) }); var onClick=function(){ ... } var onDblClick=function(){ ... }
Similar Threads
-
tree click and dblclick both raised
By mdissel in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 15 Mar 2007, 9:30 AM -
dblclick event in a grid
By neongrau in forum Ext 1.x: Help & DiscussionReplies: 3Last Post: 7 Mar 2007, 1:27 PM -
tab event
By heidtmare in forum Ext 1.x: Help & DiscussionReplies: 3Last Post: 7 Mar 2007, 9:18 AM -
using button click event for region collapsible feature
By rahulmca1@gmail.com in forum Ext 1.x: Help & DiscussionReplies: 1Last Post: 13 Feb 2007, 4:32 AM -
Event handling: Better way of doing this?
By Wolfgang in forum Ext 1.x: Help & DiscussionReplies: 3Last Post: 28 Jan 2007, 5:32 PM


Reply With Quote