首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用gquery手势插件在页面上启用文本高亮显示?

如何使用gquery手势插件在页面上启用文本高亮显示?
EN

Stack Overflow用户
提问于 2016-03-09 11:45:35
回答 1查看 56关注 0票数 0

我有一个为移动用户设计的复杂的GWT应用程序,它的(根)ApplicationPresenter中有这个gwtquery-手势-插件代码:

代码语言:javascript
复制
$(RootPanel.get())
            .as(Gesture.Gesture)
            .on("tap", new Function()
            {
                @Override
                public boolean f(Event e)
                {
                    Log.info("tap:" + e.getType() + ", x:" + e.getClientX() + ", y:" + e.getClientY());

                    // handle tap events here

                    return true;
                }
            })
            .on("swipeone", new Function()
            {
                @Override
                public boolean f(Event e)
                {
                    GestureObjects.Options o = arguments(0);
                    int delta = (int) o.delta().get(0).moved();

                    Log.info(o.description() + ":" + o.directionName() + ", x:" + e.getClientX() + ", y:" + e.getClientY() + ", delta:" + delta);

                    // handle swipe events here

                    return true;
                }

            });

不幸的是,这个插件似乎完全劫持了原生文本的选择,因此用户无法复制和粘贴任何。是否有一种方法来启用这个,或者某种解决办法?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-22 12:13:57

在对文档进行更仔细的检查时,我发现了这个静态布尔hasGestures,它可以用来检查我们是否在移动分号上加载。

所以这个片段现在变成:

代码语言:javascript
复制
if(Gesture.hasGestures) // only load for mobile devices
    {
        $(RootPanel.get())
                .as(Gesture.Gesture)
                .on("tap", new Function() 
                {
                    @Override
                    public boolean f(Event e)
                    {
                        Log.info("tap:" + e.getType() + ", x:" + e.getClientX() + ", y:" + e.getClientY());

                        return true;
                    }
                })
                .on("swipeone", new Function()
                {
                    @Override
                    public boolean f(Event e)
                    {
                        GestureObjects.Options o = arguments(0);
                        int delta = (int) o.delta().get(0).moved();

                        Log.info(o.description() + ":" + o.directionName() + ", x:" + e.getClientX() + ", y:" + e.getClientY() + ", delta:" + delta);

                        return true;
                    }

                });
    }
    else
    {
        Log.info("Not adding gesture handlers as this is not a mobile device!");
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35890715

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档