I have a panel on my activity and this is what I am trying to do
1. If the user clicks on the panel, another activity should open up
2. If the user holds a touch on the panel, another smaller panel will display like an overlay on the bottom part of the screen, providing a tool-tip. When the user releases the touch, this panel should go away
Problem is the Touch event fires for both Click and Touch. How can I detect these two separately?
But I need to detect when the user lifts the finger and releases the touch, so that I can hide the tool-tip overlay panel. I believe that can be done only by checking if Action parameter of Touch event is Activity.ACTION_UP.
But Touch event gets fired when the user clicks as well.
Sub panel1_Touch (Action As Int, X As Float, Y As Float)
If Action = Activity.ACTION_UP Then
'handle ACTION_UP event
Log("ACTION_UP")
Dim v As View
v = Sender
If X > 0 AND X < v.Width AND Y > 0 AND Y < v.Height Then
'handle CLICK event
Log("click")
End If
End If
End Sub
Sub panel_Touch (Action As Int, x As Float, y As Float)
dim touchstart, touchduration as long
If Action = Activity.ACTION_UP Then
touchduration = DateTime.Now - touchstart ' calculate touch duration
if touchduration < 400 then ' Short click
else ' long click/touch
end if
Else If Action = Activity.ACTION_DOWN Then
touchstart = DateTime.Now ' remember exact time of touch event
End If