我有一个复杂的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;
}
});
不幸的是,这个插件似乎完全劫持了文本的本机选择,因此用户无法复制和粘贴任何内容。有没有办法启用此功能或某种解决方法?
在仔细检查文档时,我发现了这个静态布尔hasGestures
,可用于检查我们是否正在加载移动 decive。
所以片段现在变成:
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!");
}