开发者

Handling onTouchEvent inside a view that also responds to onTouchEvent (used to work in OSMdroid 3.0.2)

I am currently using osmdroid jar 3.0.1, and I have a MapView inside a "Dragable Space" (a view that you can swipe between screens). I have a bar at the bottom that lets the user swipe between the spaces, and if the touch event occurs outside that area, I call mapView.onTouchEvent(event).

This used to work well in 3.0.1, but I tried in osmdroid 3.0.4, and it only appears to work for vertical movement (which I suspect is related to some touch slop setting).

Here is the code from my Dragable Space view.

@Override
public boolean onTouchEvent(MotionEvent event) {
    // Check if th开发者_运维知识库e current space is the Map space and we are over the map
    // difference is the Y value between the top and bottom of the map area.
    if (this.mCurrentScreen == 1
                    && event.getY() >= topY && event.getY() <= difference){
            Log.d(TAG, "touch received inside Map Area");
            // Pass the event directly to the mapView.
            return mOsmv.onTouchEvent(event);
    }
    Log.d(TAG, "touch received outside Map Area");
    return super.onTouchEvent(event);
}

Although this is nasty (the view has to be passed an instance of the map), it did work fine in versions 3.0.1 and 3.0.2. However, since 3.0.3 it no longer works.

Is there a better way to pass touch events to the osmdroid map now?

I have a demo project that illustrates this problem. The full eclipse project is on github.

You can change the build path to use a 3.0.1 or 3.0.2 jar, and the map scrolls around correctly inside the larger space, but changing to 3.0.3 or 3.0.4 and any sideways movement is ignored.

Any guidance would be greatly appreciated.

PS, this is a cross post from the OSMdroid list. I hope there are a few more readers here.


The problem was that MapView.onTouchEvent was renamed to MapView.dispatchTouchEvent between versions 3.0.2 and 3.0.3

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜