简体   繁体   中英

Javascript touchend event will not fire on Android

I'm trying to use the touchend (or the taphold event, both wont fire) as specified by jquery mobile. I'm developping an app for android using the phonegap platform. My AVD runs Android 4.0.3, and my phonegap version is 1.3.0.

As im using phonegap, i'm coding in javascript, and the objective is to recuperate the text selected by the user after a longpress on a word with the following code.

var selectAction = function(){
    LOGGER.log('event.js : selectAction');
};

function selectMobile(component){
    component.addEventListener('touchend',selectAction,false);
}

It actually works fine, if I tap relatively quickly, the event will fire up and I can get the log message. However, a rapid touch will not select text (I have more code taking the selected text but this is not the issue)

When a user long presses in Android, a default ''Action Menu'' pops up, and this seems to block further events from firing up. Because of that, I never get into my selectAction when actual text is selected.

Does anybody know how to properly get selected text in an html/javascript on an Android platform ?

Thank you very much.

It's could be related to below bug. http://code.google.com/p/android/issues/detail?id=19827

try catch touchmove and call e.preventDefault()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM