Android Question Event Touch&LongClick

Blueforcer

Well-Known Member
Licensed User
Longtime User
Hallo,

im unable to detect the Panel events, Touch (for sliding) and LongClick (for another function).

Is there a way to detect both at the same time?
 

BeneBarros

Active Member
Licensed User
Longtime User
Hallo,

im unable to detect the Panel events, Touch (for sliding) and LongClick (for another function).

Is there a way to detect both at the same time?

have you tried
B4X:
Sub Globals
    Private tmpX, tmpY, Tolerance as Float
end sub

Private Sub pn_Touch (Action As Int, X As Float, Y As Float)
    Dim pn As Panel = Sender
    Tolerance = 5
    Select Action
        Case Activity.ACTION_DOWN
            tmpX = X
            tmpY = Y
        Case Activity.ACTION_UP
            If Abs(tmpx - X) > Tolerance Or Abs(tmpY - Y) > tolerance Then
                'Slid
            Else
                'Touch
            End If
        Case Activity.ACTION_MOVE
    End Select
End Sub
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
If you want to detect the Touch event AND a LongClick at the same time you need to make it on your own in the Touche event.
Use a global variable and set it to the current time in MouseDown.
Then in MouseUp, check the time elapsed since MouseDown and may be, if necessary, check the postion to distiguih between a click and a Move.
 
Upvote 0
Top