Android: Disable text selection in a webview

后端 未结 7 713
误落风尘
误落风尘 2020-11-27 11:42

I am using a webview to present some formatted stuff in my app. For some interaction (which are specific to certain dom elements) I use javascript and WebView.addJavas

7条回答
  •  无人及你
    2020-11-27 12:31

    I figured it out!! This is how you can implement your own longtouchlistener. In the function longTouch you can make a call to your javascript interface.

    var touching = null;
    $('selector').each(function() {
        this.addEventListener("touchstart", function(e) {
            e.preventDefault();
            touching = window.setTimeout(longTouch, 500, true);
        }, false);
        this.addEventListener("touchend", function(e) {
            e.preventDefault();
            window.clearTimeout(touching);
        }, false);
    });
    
    function longTouch(e) {
        // do something!
    }
    

    This works.

提交回复
热议问题