PDA

View Full Version : Android, Touch Event - CR.



John Doe01
14 Apr 2011, 12:42 PM
Hi everyone,

In a word, there is next issue in my sencha-application. I have the custom component - map ( btw, it's based on the dojo, it listens to some events from user, such as a click, mouse up, mouse down, mouse drag ).

So, talking of Android, I have the situation in which my custom map control don't get the events, cause there is next code in the Sencha:


onTouchStart: function(e) {
var targets = [],
target = e.target;

if (e.stopped === true) {
return;
}

if (Ext.is.Android) {
if (!(target.tagName && ['input', 'textarea', 'select'].indexOf(target.tagName.toLowerCase()) !== -1)) {
e.preventDefault();
}
}

if (this.isFrozen) {
return;
}

// There's already a touchstart without any touchend!
// This used to happen on HTC Desire and HTC Incredible
// We have to clean it up
if (this.startEvent) {
this.onTouchEnd(e);
}

this.locks = {};

this.currentTargets = [target];

while (target) {
if (this.targets.indexOf(target) !== -1) {
targets.unshift(target);
}

target = target.parentNode;
this.currentTargets.push(target);
}

this.startEvent = e;
this.startPoint = Ext.util.Point.fromEvent(e);
this.lastMovePoint = null;
this.isClick = true;
this.handleTargets(targets, e);
},



As you guys may see, e.preventDefault() stops propogation of this events for custom component.
Since mapComponent is just a canvas, I have tried to add next condition:


if (!(target.tagName && ['input', 'textarea', 'select', 'canvas'].indexOf(target.tagName.toLowerCase()) !== -1)) {
e.preventDefault();
}

It part helps, but when I emulate longtap (click+timer), it fires safari browser magnifying glass.

Are there ability to prevent magnifying glass appereance? Or may be there is something workaround for click events of custom components based on canvas.

Thanks.