View Full Version : touch event on Android

30 Jun 2010, 10:04 PM
I am testing on Android Eclair. However, the touch event is not working....I am testing with example/tab, and the touch tab does nothing.

For you information, On Android Eclair, web view javascript touchstart does not work.
Only mousedown/mouseup event works.

document.addEventListener("touchstart", function(event) {
window.androidLogger.trace("TTTTTouch SSSSStart event!!!");
}, false);

document.addEventListener("mousedown", function(event) {
window.androidLogger.trace("MMMMMMMMouse DDDDown event!!!");
}, false);

Have you guys really tested on Android ?

1 Jul 2010, 11:57 AM
What version of Android is this? We support Android 2+. If there are no touch events we can't support it. :/

1 Jul 2010, 12:37 PM
Isn't Eclair 2.1?

Yep it's 2.0/2.1

2.0/2.1 (Eclair)
Based on Linux Kernel 2.6.29

1 Jul 2010, 1:31 PM
So if it is 2.1, how come it doesn't support touch events?

1 Jul 2010, 1:34 PM
I think the key word here is web view and not the internal browser.


1 Jul 2010, 1:43 PM
Aha! Hmm, I have no experience with that. One of the first things that I could think about is the fact that the webview has a touchstart defined in window, but doesnt actually implement or fire it. Thus our feature detection breaks. You could try doing Ext.platform.hasTouch = false and see if that helps. That will make it fall back to mouse events.

1 Jul 2010, 1:51 PM
This also might be fixed under 2.2.

Life0fun could probably test it faster then me at least concerning this July 4th weekend :D

1 Jul 2010, 8:29 PM
All, thanks for the reply. aw1zard2 got the point, it is webview, not the browser.
Basically, the onTouch() inside webview works fine....however, the JS loaded by webview, there is no touch event, (touchstart, touchend) not working......only mousedown and mouseup, and click works in Java Script. In JQTouch, I just changed the function to catch mouse down and it works. Here in Sencha, not sure how to change it....might be as simple as I have done on JQTouch, not sure.

One more thing, how do you guys cook up web apps ? the way I am doing is load html and js through web view, with files dump to asset folder.....isn't this the default way ? or I am missing something...

1 Jul 2010, 8:35 PM
As Tommy also said try using this life0fun.

Ext.platform.hasTouch = false;

See if that fixes your problem using the webview instead of the browser.

3 Jul 2010, 11:01 AM
Yes, I changed the setting inside ext-touch-debug.js

hasTouch: ('ontouchstart' in window) to hasTouch: false.

Is there a way to set this outside the ext-touch.js ?
I put Ext.platform.hasTouch=false inside application's Ext setup, Ext.setup({...}) or outside it...but it does not take effect.

I checked the code, this controls which event listener to add during the init....so I guess no way to set it after init ?

4 Oct 2010, 10:08 AM
I can verify that this is a problem on both the webview and regular android browsers. The behavior is there on my 2.2 device and the SDK's emulator. The problem exists when using a webview and when visiting the demo application through the regular web browser (http://dev.sencha.com/deploy/touch/examples/map/).

Searching ext-touch-debug.js for "hasTouch" shows no results.

6 Oct 2010, 12:52 PM
The if block at line 14237 of ext-touch-debug.js seems to be causing the problem. I don't know the reason for this code, but if commented out, our maps work. It is a piece of code in Ext.gestures.Manager.

if (Ext.is.Android) {
if (!(/input|select|textarea/i.test(target.tagName))) {