0

モバイル用に設計された複雑な 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;
                }

            });

残念ながら、このプラグインはテキストのネイティブ選択を完全にハイジャックしているように見えるため、ユーザーは何もコピーして貼り付けることができません。これを有効にする方法、または何らかの回避策はありますか?

4

1 に答える 1

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!");
    }
于 2016-03-22T12:13:57.270 に答える