禁用文本选择中的PhoneGap [英] Disabling text selection in PhoneGap

查看:143
本文介绍了禁用文本选择中的PhoneGap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

时可以禁用文本选择做一个PhoneGap的应用程序更类似于正常的本机应用程序?

Is it possible to disable text selection to make a PhoneGap app more similar to normal native app?

事情是这样的:

document.onselectstart = function() {return false;}

* { 
user-select: none;
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
}

或许多其他事情不工作。

Or many other things don't work.

推荐答案

我看遍了这个帮助。这终于为我工作。

I looked all over for help on this. This finally worked for me.

public class MainActivity extends DroidGap {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        super.loadUrl("file:///android_asset/www/index.html");

        super.appView.setOnLongClickListener(new View.OnLongClickListener() {

            public boolean onLongClick(View v) {
                return true;
            }
        });
    }
}

该setOnClickListener是什么呢神奇。请确保你把这个您的来电super.loadUrl后。

The setOnClickListener is what does the magic. Make sure you put this AFTER your call to super.loadUrl.

当然,这将禁用文本选择为您的整个应用程序,但我与确定,我没有周围没有任何其他的方式了。

Of course, this will disable text selection for your entire app, but I'm OK with that, and I don't have any other way around it for now.

我不知道本作的完整含义,但我做利用JqueryMobile事件taphold的,它仍然能正常工作。我相信这部作品通过处理长点击appView(它承载你的HTML应用程序)和$ P $向上冒泡pventing吧。

I'm not sure of the complete implications of this yet, but I do make use of the JqueryMobile event "taphold", and it still works fine. I believe this works by handling the long click on the appView (which hosts your HTML app) and preventing it from bubbling up.

这篇关于禁用文本选择中的PhoneGap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆