Detecting Touch and Click separately on a panel

Inman

Well-Known Member
Licensed User
Longtime User
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?
 

Inman

Well-Known Member
Licensed User
Longtime User
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.
 
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User
Thanks Erel. But that still shows both Action_Up and click when I touch on the panel.

Anyway leave it. I dropped the idea and switched to toast message instead.
 
Upvote 0

ukimiku

Active Member
Licensed User
Longtime User
I did it like this with a panel:

B4X:
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

Hope this helps.

Regards,
 
Upvote 0
Top