Android Question Issue with Handling Horizontal and Vertical Swipes on a Panel

KZero

Active Member
Licensed User
Longtime User
Hello,

I'm using reflection to manage touch events on a Panel. My goal is to handle only horizontal swipes while allowing vertical swipes to pass through to the ListView behind the Panel.

I've tried the following code, which triggers "return false" on a vertical swipe, but the touches still don't pass through to the ListView.

B4X:
Private Sub Panel_onTouch(ViewTag As Object, Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
    If Action = 0 Then
        StartX = X
        StartY = Y
    End If

    If Action = 2 Then
        Dim deltaX As Float = Abs(X - StartX)
        Dim deltaY As Float = Abs(y - StartY)

        LogColor(deltaY  & " - " & deltaX ,Colors.Yellow)
        
        If (deltaY) > (deltaX)  Then
            Log("PASS THE TOUCHES")
            Return False
        End If


        return true
    End If
 

teddybear

Well-Known Member
Licensed User
You should use onInterceptTouch Event instead of onTouch.
 
Upvote 0
Top