Duplicated tap event on android 4.1 Jelly Bean with enyo 1.0

edited July 2012 in Enyo 1.0
this code run fine in Chrome and in all previous version of android but with android 4.1 (using phonegap) "itemClick" get called 2 times when I click on the button. I have no idea what can cause this problem. Can someone help me? Thansk in advance
enyo.kind({
	name: "TestApp",
	kind: "VFlexBox",
	
	components: [
		{kind: "Button", content:"click Me", onclick:"itemClick"},
		{kind:"Control",content:""}
		
	],
	create: function() {
		this.inherited(arguments);
		this.i=0;

	},
	itemClick: function(inSender, inEvent) {
		this.i++
		var a = this.$.control.getContent();
		this.$.control.setContent(a+" test"+this.i)
	}
	
});

Comments

  • Put a return true; at the end of your function and see if that keeps the double-run from happening.
  • edited July 2012
    return true doen't have any effect (it seems its only used on enyo 2 not enyo 1)

    It seems that android >=4.1 generate a native click event after the touchend event. In webkitgesture.js, enyo generate a custom click event (after it receive a touchend event) for non-webos plattforms and that why I get 2 click events.

    I ended up preventing the native click event with the following code:
    
    create: function() {
           if(!window.PalmSystem&&( window.device != undefined && window.device.platform != undefined )){
    		document.addEventListener("click", enyo.bind(this,this.preventNativeClick), true);
    		
    	}
    },
    
    preventNativeClick: function(inEvent) {
    	//Catch native click event on some android platfom
    	if(window.device != undefined && window.device.platform != undefined&&inEvent.timeStamp!=undefined){
    		inEvent.preventDefault();
    		inEvent.stopPropagation();
    	}
    },
    
Sign In or Register to comment.