Android Question Touch Event for panels designed in code

Discussion in 'Android Questions' started by bogdanc, Mar 29, 2015.

  1. bogdanc

    bogdanc Active Member Licensed User

    Hot to get touch event for panels designed in code.
    I have in loop:
    Code:
    panel(i).Initialize("panButBottom")

    I called like this but the key is null.

    Code:
    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: Mar 29, 2015
  2. klaus

    klaus Expert Licensed User

    Something like this:
    Code:
    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
     
    Erel, bogdanc and NJDude like this.
  3. bogdanc

    bogdanc Active Member Licensed User

    Thanks Klaus.

    That was my mistake of non declared the panel(i).Tag=i
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice