Android Question Panel Touch Actions

chris ash

Member
Licensed User
Longtime User
Hi guys

Just after help with getting a panel to behave in an app that I am working on.

I am using : Private Sub pnlStartButton_Touch (Action As Int, X As Float, Y As Float) As Boolean

My question is simply what are the actions. Looking through all the basic documentation and other support requests it would seem the main 3 are...

As per @klaus

0=ACTION_DOWN if the user just touched the View
2=ACTION_MOVE if the user is still touching the View and moves the finger
1=ACTION_UP the user just released the touching the View

My question is then why am I sometimes getting action 3?

To explain what I am trying to do (see below code also)...

During the game the player can long press on the panel. To pause the action of the game (and turn a panel Red for paused), this is caught by Action_Down.

When they release the panel the action resumes (Should be ACTION_UP).

BUT the player needs to be able to press the panel again very quickly to make their selection. Using the same panel and again the ACTION_DOWN.

The problem seems be that occasionally the ACTION_UP command does not trigger, and the game remains paused when then panel is not being touched any longer. Looking into the logs I have seen another ACTION, Action No 3. Adding this as an up command seemed to resolve the issue, but there are still very infrequent situations where the UP is not captured and the game gets stuck.

Does anybody have any idea about any other ACTIONS that I may not be aware of they I may need to capture and deal with?

With the rapid press, release and press I wondered if there as some sort of action specifically for double tapping for something like that? Although I cannot see anything in the documentation about that anywhere else. Or is there an alternative mented I can use to get my desired effect?

B4X:
Private Sub pnlStartButton_Touch (Action As Int, X As Float, Y As Float) As Boolean
    
    'Down = 0
    'Up = 1
    'Move = 2
    
    '3 = Up Maybe
    
    Select Action
      Case Activity.ACTION_DOWN       
        IsStartButtonDepressed = True
        pnlStartStatus.Color = Colors.Red
        StartButtonClick
        Log("Down " & Action)
       Case Activity.ACTION_UP
        IsStartButtonDepressed = False
        pnlStartStatus.Color = Colors.Green
        Log("Up" & Action)

    Case Activity.ACTION_MOVE
        Log("Move " & Action)
        
    Case 3
        IsStartButtonDepressed = False
        pnlStartStatus.Color = Colors.Green
        Log("Up 3" & Action)
    
    Case Else
        Log ("Other " & Action)
    End Select
    
End Sub

Thanks in advance

CAsh
 

DonManfred

Expert
Licensed User
Longtime User
  • Like
Reactions: byz
Upvote 0

PaulMeuris

Well-Known Member
Licensed User
And in the same webpage...

ACTION_CANCEL​

Added in API level 1


public static final int ACTION_CANCEL
Constant for getActionMasked(): The current gesture has been aborted. You will not receive any more points in it. You should treat this as an up event, but not perform any action that you normally would.



Constant Value: 3 (0x00000003)
 
Upvote 0
Top