How to prevent firing single click event when double clicked in extjs -


i have tree panel , each node have single click , double click events. when double click firing single click event also. how prevent firing single click event when double clicked?

generally using both single click , double click events considered bad practice , highly discouraged.

however, if still want this, way able distinct between single click , double click artificially add distintion measuring time between clicks.

the idea don't single-click action right away wait second click. if second click comes shortly, double click action gets triggered. otherwise single click action gets triggered after delay.

your code like:

var singleclicktask = new ext.util.delayedtask(singleclickaction),  // our delayed task single click     singleclickdelay = 100; // delay in milliseconds  function onclick() {     singleclicktask.delay(singleclickdelay); }  function ondblclick() {     // double click detected - trigger double click action     doubleclickaction();     // , don't forget cancel single click task!     singleclicktask.cancel(); }  function singleclickaction() {     // useful... }  function doubleclickaction() {     // useful... }   // setting event handlers on element elem.on('click', onclick); elem.on('dblclick', ondblclick); 

the obvious downsides are:

  • there delay single click action
  • in different os there can different setting interval between clicks trigger double click, hard-coding singleclickdelay not reliable
  • javascript timer isn't 100% accurate , results may differ on systems different performance

i don't know better solution, , again, discourage using both single , double clicks @ same time, leads broken user experience.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -