Android Question Touch Event for panels designed in code

bogdanc

Active Member
Licensed User
Hot to get touch event for panels designed in code.
I have in loop:
B4X:
panel(i).Initialize("panButBottom")

I called like this but the key is null.

B4X:
Sub panButBottom_Touch (Action As Int, X As Float, Y As Float) As Boolean 'Return True to consume the event

   Select Action
      Case Activity.ACTION_DOWN
       Dim key As Panel
         key = Sender
        Msgbox("Down:" & key.Tag ,"")
      Case Activity.ACTION_MOVE
         Log("move")
      
      Case Activity.ACTION_UP
         Log("up")
   End Select
   Return True
End Sub
 
Last edited:

klaus

Expert
Licensed User
Something like this:
B4X:
panel(i).Initialize("panButBottom")
panel(i).Tag = i

Sub panButBottom_Touch (Action As Int, X As Float, Y As Float)
    Dim pnl As Panel
    Dim key As Int
    pnl = Sender
    key = pnl.Tag
 
Top