2016-03-09 32 views
0

我有一個是專爲移動和具有該gwtquery-gestures-plugin代碼在其(根)ApplicationPresenter一個複雜的GWT應用:如何使用gquery手勢插件在頁面上啓用文本高亮顯示?

$(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; 
       } 

      }); 

不幸的是這個插件似乎完全劫持文本的本土選擇,所以用戶可以不要複製和粘貼任何東西。有沒有辦法啓用此功能或某種解決方法?

回答

0

在仔細檢查文檔後,我發現這個靜態布爾值爲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!"); 
    } 
相關問題