PDA

View Full Version : image event handling issue



sandy52
3 Feb 2014, 12:55 AM
Hi,
I have created event listener of image for click and double click event handling, but i am getting issue like when i click on image single click event fire and when i am doing double click on image it fire both events my code is :

{
xtype: 'image', src: 'resource/images/spoon_icon.png',id:'SpoonImg', cls: 'spoonIcon', border: 15,
listeners: {
el: {
dblclick: function () {
var viewPort = Ext.ComponentQuery.query('viewport')[0];
var t = viewPort.getLayout().setActiveItem(0);

},
click: function () {
var win;


if (!win) {

win = Ext.widget('NavPanel');
}

if (win.isVisible()) {
win.hide();

} else {
win.show();
}

}

}
}
},


How can i handle this both??? help me...:((

regards,
sandy

palakurthivishal
3 Feb 2014, 9:49 AM
Hello sandy52 (http://www.sencha.com/forum/member.php?661059-sandy52) ,
I tried some ways to resolve your issue, but couldn't find any solution. :((

Prasad_Guduri
3 Feb 2014, 12:03 PM
Hi Sandy,

Here you need to delay the the single click action for some time.

When one more click hapend....it will trigger the double click event.

Inside double click event kill the single click event.

Example:

var singleClickTask = new Ext.util.DelayedTask(singleClickAction), // our delayed task for single click singleClickDelay = 100; // delay in milliseconds function onClick() { singleClickTask.delay(singleClickDelay); } function onDblClick() { // double click detected - trigger double click action doubleClickAction(); // and don't forget to cancel single click task! singleClickTask.cancel(); } function singleClickAction() { // something useful... } function doubleClickAction() { // something useful... }Regards,
Prasad Guduri