1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    225
    Vote Rating
    0
    seldon is on a distinguished road

      0  

    Default 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

  2. #2
    Ext JS Premium Member prophet's Avatar
    Join Date
    Mar 2007
    Location
    Greenwich, CT
    Posts
    187
    Vote Rating
    0
    prophet is on a distinguished road

      0  

    Default


    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
    ..
    ..
    }

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    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');
    },

  4. #4
    Ext User
    Join Date
    Mar 2007
    Posts
    225
    Vote Rating
    0
    seldon is on a distinguished road

      0  

    Default


    I was hoping there would be a more yui-ext like way? Using stopevent or prevendefault in some way?

  5. #5
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    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.

  6. #6
    Sencha User
    Join Date
    Aug 2010
    Posts
    5
    Vote Rating
    1
    Al Jey is on a distinguished road

      0  

    Default


    The more ExtJS like way would be:

    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(){
        ...
    }
    The double click timeout of 500ms is default on windows, so I think that it's the most appropriate value here.

Similar Threads

  1. tree click and dblclick both raised
    By mdissel in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 15 Mar 2007, 9:30 AM
  2. dblclick event in a grid
    By neongrau in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 7 Mar 2007, 1:27 PM
  3. tab event
    By heidtmare in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 7 Mar 2007, 9:18 AM
  4. using button click event for region collapsible feature
    By rahulmca1@gmail.com in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 13 Feb 2007, 4:32 AM
  5. Event handling: Better way of doing this?
    By Wolfgang in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 28 Jan 2007, 5:32 PM

Thread Participants: 3

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi