question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

All touch events are consumed by CustomViewAbove

See original GitHub issue

If I use the SlidingMenu together with ActionBarSherlock (maybe unrelated) and with this settings:

SlidingMenu sm = getSlidingMenu();
sm.setShadowWidthRes(R.dimen.shadow_width);
sm.setShadowDrawable(R.drawable.shadow);
sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
sm.setFadeDegree(0.35f);
sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
sm.setTouchModeBehind(SlidingMenu.TOUCHMODE_FULLSCREEN);

I cannot use the view behind which has the effect that I cannot react on onListItemClick(...) in my ListFragment after days of research I found out that there is a bug in the CustomViewAbove.

My primary fix is to change a break in onInterceptTouchEvent() to return mQuickReturn;. So the ACTION_DOWN event code will look like this:

case MotionEvent.ACTION_DOWN:
    int index = MotionEventCompat.getActionIndex(ev);
    mActivePointerId = MotionEventCompat.getPointerId(ev, index);
    if (mActivePointerId == INVALID_POINTER)
        break;
    mLastMotionX = mInitialMotionX = MotionEventCompat.getX(ev, index);
    mLastMotionY = MotionEventCompat.getY(ev, index);
    if (thisTouchAllowed(ev)) {
        mIsBeingDragged = false;
        mIsUnableToDrag = false;
        if (isMenuOpen() && mViewBehind.menuTouchInQuickReturn(mContent, mCurItem, ev.getX() + mScrollX)) {
            mQuickReturn = true;
        }
    } else {
        mIsUnableToDrag = true;
    }
    return mQuickReturn;

Update: And also the onTouchEvent you need to change the case MotionEvent.ACTION_DOWN. There you need to replace the break with another return mQuickReturn. The case will look like that:

case MotionEvent.ACTION_DOWN:
    /*
     * If being flinged and user touches, stop the fling. isFinished
     * will be false if being flinged.
     */
    completeScroll();

    // Remember where the motion event started
    int index = MotionEventCompat.getActionIndex(ev);
    mActivePointerId = MotionEventCompat.getPointerId(ev, index);
    mLastMotionX = mInitialMotionX = ev.getX();
    return mQuickReturn;

</update>

I also removed the setInternalPageChangeListener in initCustomViewAbove(). (The reason comes later.)

In the CustomViewBehind I changed the code of the functions onInterceptTouchEvent and onTouchEvent to use the code from the CustomViewAbove:

@Override
public boolean onInterceptTouchEvent(MotionEvent e) {
    return !mChildrenEnabled;
}

@Override
public boolean onTouchEvent(MotionEvent e) {
    return !mChildrenEnabled;
}

Now the part with the ChildrenEnabled is not anymore used and the function setChildrenEnabled and the member mChildrenEnabled can be removed.

Hopfully this will help others. By the way I would like to make a PushRequest but I don’t know how to make that.

Issue Analytics

  • State:open
  • Created 10 years ago
  • Comments:31

github_iconTop GitHub Comments

1reaction
ssyandroidcommented, Mar 29, 2016

thanks

1reaction
DawnYu9commented, Aug 29, 2015

@MicoDevelopers thank you very much!!!It works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

iOS custom view consuming touch events - Stack Overflow
I am implementing a custom view to handle editing of a image(very specific purpose) and am stuck in handling of touch events.
Read more >
Touch events - Web APIs - MDN Web Docs - Mozilla
Touch events are similar to mouse events except they support simultaneous touches and at different locations on the touch surface. The ...
Read more >
How touch events are delivered in Android - Suragch - Medium
When a touch event occurs, first everyone is notified of the event, starting at the Activity and going all the way to the...
Read more >
Manage touch events in a ViewGroup - Android Developers
Touch slop is typically used to prevent accidental scrolling when the user is performing some other touch operation, such as touching on-screen ...
Read more >
Handling JavaFX Events: Working with Touch Events
See Touch Events Example for an example of how touch events can be used in a ... Because events in the event set...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found