[英]How to enable text highlighting on a page using gquery gestures plugin?
我有一個專為移動設備設計的復雜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
可用於檢查我們是否在移動設備上加載。
現在,代碼段變為:
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.