[英]How to enable text highlighting on a page using gquery gestures plugin?
I have a complex GWT application that is designed for mobile and has this gwtquery-gestures-plugin code in its (root) ApplicationPresenter: 我有一个专为移动设备设计的复杂GWT应用程序,其(根)ApplicationPresenter中具有以下gwtquery-gestures-plugin代码:
$(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;
}
});
Unfortunately this plugin seems to totally hijack the native selection of text, so the user can't copy and paste anything . 不幸的是,此插件似乎完全劫持了文本的本机选择,因此用户无法复制和粘贴任何内容 。 Is there a way to enable this, or a workaround of some kind? 有没有一种方法可以启用此功能,或者有某种解决方法?
On closer inspection of the documentation, I found this static boolean hasGestures
that can be used to check if we are loading on a mobile decive or not. 在仔细检查文档时,我发现此静态布尔hasGestures
可用于检查我们是否在移动设备上加载。
So the snippet now becomes: 现在,代码段变为:
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!");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.